x
login about faq Site discussion (meta-askssc)

Insert into identity column table use that identity column value to insert in second table

I have 2 tables. I need to insert row to a table so that i will get the identity column value using that identity column value i need to add a row in the second table.How to do it without using triggers? Table 1: userid identitycolumn primary key val1 varchar null val2 varchar null

Table2 userid not null value3 null value4 null

more ▼

asked Jul 04 '10 at 06:50 PM in Default

winza gravatar image

winza
2 1 2

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

            
INSERT Table1 (val1,val2)            
OUTPUT Inserted.UserID,NULL,NULL INTO Table2            
VALUES('1','2')            
more ▼

answered Jul 04 '10 at 08:20 PM

Scot Hauder gravatar image

Scot Hauder
5.7k 13 15 18

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x91

asked: Jul 04 '10 at 06:50 PM

Seen: 479 times

Last Updated: Jul 04 '10 at 06:50 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.