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 |
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2006-06-21 : 12:44:04
|
| I have a table called master:Ticket_id Ticket_date-------- ---------------Ticket_id is a identity column , so whenever there is an insert into the master table, a ticketid is generated automatically..I am trying to insert the ticketid to the detail table which has the the foreign key relationship with the master table at the same time the insert got occured in the master table --Detail tableId Ticketid--- ---------How can I do this by using the insert statements?master insertinsert master ( tiacketdate) value ( @ticketdate)select scope_identity()--I would like to insert the value of scope_identity() from the master table to the ticketid in detail table.... insert detail ( ?? ) |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-06-21 : 12:50:04
|
| insert into mastertable values (x, y)select @someid = scope_identity()insert into detail values (@someid, 'name', 'something other')Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|