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.
Author |
Topic |
jerryleguer
Starting Member
2 Posts |
Posted - 2010-12-03 : 10:04:07
|
Hello, I need to insert in to tow tables. The firts table creates an Identity and that identity has to be inserted into the second table. Table 1id (identity)Failed CommentsTable 2idtypeidtable1dateCommentsI need to insert a new record on table and then insert a new record in table 2 using the table 1 identity row for the idtable1. Thans |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-12-03 : 10:13:01
|
declare @id intinsert tbl1 (failed, comments) select 'asdfafd', 'csc\x'select @id = scope_identity()insert tbl2 (type, idtable1, date, comments)sleect 1, @id, getdate(), 'fdsgsfg'==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
bobmcclellan
Starting Member
46 Posts |
Posted - 2010-12-03 : 10:14:28
|
declare @si intInsert into table 1 (...)set @si = scope_identity()Insert into table 2 (id, ...values ( @si, ... )hth,bob |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
|
|
|