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 |
|
dotosu
Starting Member
42 Posts |
Posted - 2004-01-15 : 22:45:15
|
| Hello,I have this temp table in the db which has all this data. I want to insert this data into three different tables that are joined together. How can I do this? Right now the only way that I can see is to use a cursor: Insert record 1, find PK of that record, Insert related records to the joined tables. But this does not seem like an efficient solution. Can someone please let me know if there is another way of doing this? I would appreciate it.Thanks in advance,dotosu |
|
|
raymondpeacock
Constraint Violating Yak Guru
367 Posts |
Posted - 2004-01-16 : 04:51:01
|
| I can't think of an easy way to do this as the insert statement can only affect one table. Even updateable views are not an option as they have to be based on one table only.You could simplify the searching for PKs by using identity columns and the @@identity variable to determine the id of the record inserted into table to then use as the key for the insert into table 2 etc.Raymond |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-01-16 : 05:46:10
|
| DO you have any candidate keys in thye table generating the identity? If so you can join on that.If not then you can create the identity values in the temp table and insert using identity insert.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|