Update Last Record in SQL Server 2005

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Adithya Adi
    New Member
    • Oct 2011
    • 12

    Update Last Record in SQL Server 2005

    Table name: shift_Login
    columns:ID, Username, TimeLogin, TimeLogoff

    Username and password is Checked from another table.
    1.ID is AutoNumber,
    2.Username is taken from the login form directly(Text Box)
    3.TimeLogin is taken (current time) from the button click

    only one can login at a time.
    user will logoff after all the process.

    when logging out - TimeLogoff should be entered directly to the shift_login table(current time).

    anyway TimeLogoff will be entered in the last row.

    Can u please send me the query to update the last row in the table.
  • gpl
    New Member
    • Jul 2007
    • 152

    #2
    In the context of an SQL table, last row is meaningless

    however, this should do what you ask
    Code:
    Select Max(TimeLogoff)
    From shift_Login

    Comment

    • Adithya Adi
      New Member
      • Oct 2011
      • 12

      #3
      thanks for the code.. its not that I meant.. but that was enough.. I got the idea to do from your code..
      The code actually need for me was ------
      "update ShiftLogin set shftlgn_time_of f = 'xxxxxxxx' where shftlgn_empid = (Select Max(shftlgn_emp id) From ShiftLogin)"

      Comment

      Working...