Tuesday, July 29, 2014

how to get last column


insert into address


memberid (this should be above memberid)


how do i get same meberid , that i just inserted .



You can use SCOPE_IDENTITY() to get the last identity value inserted in the current scope:



INSERT INTO address (memberid, address_line_1)
SELECT SCOPE_IDENTITY(), @address_line_1;






Dan Guzman, SQL Server MVP, http://www.dbdelta.com


No comments:

Post a Comment