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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Multi-Table Insert ...

Author  Topic 

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-05-08 : 07:05:43
Hi all,

can I insert in multiple tables in a single statement?

thanks in advance,

BMahesh

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-08 : 07:09:55
What are you trying to achieve ?


KH

Go to Top of Page

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2006-05-08 : 07:11:02
Only by inserting into a view with an instead-of trigger that contains separate inserts into multiple tables. Look up "INSTEAD OF INSERT triggers" in BOL.

Mark
Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-05-08 : 07:18:39
hi khtan,

suppose i have 3 tables t1, t2, t3 respectively. they all have same table structure. t1, t2 are the blank tables where as the t3 have 50 records. I want to insert into t1, t2 the values of t3 by writing a single statement. instead of insert into t1 (select * from t3) AND
insert into t2 (select * from t3).

thanx in advance,





BMahesh
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-08 : 07:20:49
so that will make t1 and t2 identical to t3. So wouldn't that make two of the tables redundant ?


KH

Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-05-08 : 07:24:35
I wants to know, can we do suvh things in SQL server? "Means, multi-table insert in a single statement."

BMahesh
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-08 : 07:44:09
No. The only work around that i can think of is via instead of trigger as suggested by Mark


KH

Go to Top of Page
   

- Advertisement -