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 2005 Forums
 Transact-SQL (2005)
 First inserted Identity number

Author  Topic 

erics44
Starting Member

12 Posts

Posted - 2009-12-08 : 06:36:09
Hi
If I insert 10 rows to a table do you know how i return the first identity number of these 10 rows

i know scope_identity() returns the last

Thanks in advance

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-12-08 : 07:21:28
hi

You expect this..?

SELECT IDENT_SEED('tablename')
SELECT IDENT_INCR('tablename')

-------------------------
R...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-08 : 07:34:41
Immediately after the insertion,

SELECT SCOPE_IDENTITY()-@@ROWCOUNT*IDENT_INCR('your_table')


Madhivanan

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

erics44
Starting Member

12 Posts

Posted - 2009-12-08 : 07:42:15
thanks
Go to Top of Page
   

- Advertisement -