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 2008 Forums
 Transact-SQL (2008)
 identity

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-01-04 : 06:05:06
Hi,
I am inserting several records into a table which has an identity field. Then I would like to take the inserted batch with the identity values and then insert them into another table.
Question:
How can I take the batch from the table which has the identity column?
Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-04 : 06:11:55
you have to make use of composable DML like below or use a temporary table with OUTPUT clause

http://visakhm.blogspot.com/2011/08/multiple-table-insertion-using-single.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-01-04 : 06:18:22
thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-04 : 12:30:55
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-04 : 13:21:40
quote:
Originally posted by visakh16

wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





Water Closet?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -