C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

Last affected row


Posted Date: 02 Nov 2009      Posted By: karunajo      Member Level: Silver     Points: 1   Responses: 6



Hi,

how to get a last affected rows in sqlserver





Responses

Author: Christopher    02 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Use


@@identiy or Scope_identity



Author: karunajo    02 Nov 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

Can u give me the query


Author: Dharmaraj    02 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Hi,
You can use RETURN @@IDENTITY which will return the idvalue of the last affected row.

Regards,
Dharma
Editor,Mentor,MVM
Try and fail but don't fail and try
Me and DNS



Author: Anil Kumar Pandey    02 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

hi,

where do you want to access this.. either you can use the @@IDENTITY in the SP to return the last inserted row or use a update time column to get the recent updated row..

Thanks & Regards
Anil Kumar Pandey



Author: satya    02 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

You can use IDENT_CURRENT

SELECT IDENT_CURRENT('tablename')



Author: Melchior    02 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

To find the unique id of the affected record, you can use the following query

INSERT INTO TABLE1 VALUES(F1,F2...)
SET @intLastAffectedID = @@IDENTITY

To get the number of rows affected, you can use this statement

INSERT INTO TABLE1 VALUES(F1,F2...)
SELECT @intLastAffectedID = @@IDENTITY,@intAffectedRows = @@ROWCOUNT



Post Reply
You must Sign In to post a response.
Next : DateTime
Previous : Wanna add new coloumn from c#
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use