Wednesday, March 7, 2012

How to retrieve last updated record

I have some set of records in my table.

The same set of records will be updated often. Now I have a column as "lastupdated"

While i am displaying the records in a datagrid, The LAST UPDATED record should only be displayed.

Means, the recently updated records should be displayed in datagrid.

Pls give me the sql code / i am also in need of a Stored procedure for this.

I am working in SQL 2005

SELECT TOP (1) * FROM yourTable ORDER BY lastupdated DESC

You can wrap it into a Stored Procedure:

CREATE PROCEDURE yourSP

AS

SELECT TOP (1) * FROM yourTable ORDER BY lastupdated DESC

|||

Thankyou Thankyou Thankyou,

Thanks a lot for your reply.Cool

No comments:

Post a Comment