Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to know which was the last updated Row in Table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-04-18 : 09:34:46
K. Amith Kumar writes "Hi,

I wanted to know which row was last updated in a table?
And I wanted to Select that row and use in my later programming.

Please help me it is very important for me to solve this."

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2006-04-18 : 09:36:31
SQL Server has no concept of "which row was updated last", I'm afraid. Unless there's something in your data which will indicate the order the rows were added, you're out of luck.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-18 : 09:40:39
If you use DateTime column you can query based on the maximum of it

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-18 : 09:50:12
You can use a column with datetime data type that get updates with getdate() everytime a records is updated (insert / update trigger)




KH


Go to Top of Page

a_r_satish
Yak Posting Veteran

84 Posts

Posted - 2006-04-19 : 04:52:21
use a column with datatype and for every update/insert use getdate() to fill the column.
Now u can use that column to find the last changed row

satish.r
"Way to success is always under Construction"
Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-04-20 : 08:26:30
I will suggest "After Insert / After Update Trigger" in this case. Insert such updated rows in New table and get such values for further programming.

BMahesh
Go to Top of Page
   

- Advertisement -