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 |
|
rama.nelluru
Starting Member
37 Posts |
Posted - 2012-07-25 : 13:35:37
|
| Hi ,I have to insert data into 3 tables.data i need to insert is unit1, unit2,unit3-- one table1 sn,range,area,section-----2nd table2bdate,praid,numrows,plant--------table3and all the three table are having PK AND FKON COLUMNS ID2,ID2,ID3.Please help me with this query .Thanks,RamRAM |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2012-07-25 : 13:38:41
|
| Do you need to insert data in three separate tables through a single insert query or you are facing (pk-fk) relation while inserting data in three separate tables through separate queries.--------------------------http://connectsql.blogspot.com/ |
 |
|
|
rama.nelluru
Starting Member
37 Posts |
Posted - 2012-07-25 : 13:41:53
|
quote: Originally posted by lionofdezert Do you need to insert data in three separate tables through a single insert query or you are facing (pk-fk) relation while inserting data in three separate tables through separate queries.--------------------------http://connectsql.blogspot.com/
HI,Need to insert into 3 tables with single sql statement ThanksRAM |
 |
|
|
rama.nelluru
Starting Member
37 Posts |
Posted - 2012-07-25 : 13:58:04
|
| Hi,Need to insert into 3 tables with single sql statement.Please any help ...RAM |
 |
|
|
rama.nelluru
Starting Member
37 Posts |
Posted - 2012-07-25 : 14:30:28
|
| Hi ,can any one help me on thos please ....RAM |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-07-25 : 14:59:57
|
| 1. You can't INSERT 3 tables with a single statement. The closest you can get is 2 tables using the OUTPUT clause on the first INSERT. (and this won't work due to the foreign key)2. You don't need to INSERT 3 tables with one statement, you can enclose 3 separate INSERTs in a transaction and roll it back if there's an error.3. How about providing actual DDL for your tables and some sample data? How exactly do you intend to INSERT this data anyway?4. Stop replying to bump up your post. It makes you sound needy and desperate and more important than the other posters. |
 |
|
|
|
|
|
|
|