Tuesday, June 12, 2007

Getting index value of new record created

In your T-SQL stored procedure, after you insert the new record into a table that has an auto-incrementing index, use the following:

SELECT NEWID = SCOPE_IDENTITY()
OR (if using pre 2000 sql server)
select returnval = @@identity

You can retrieve the value in the following way:
set rs = con.Execute(strSql)
yournewID = rs(0)

Labels:

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home