Insert Into Multiple tables from single select
-
06 Maret 2012 7:29
Can we insert into multiple tables from a single select statement?
e.g. I have a flat file consisting of Person data with his/her address, And in the database I have 2 tables person and address.
Now can we insert the data in both the tables from a single select statement?
.Net
Semua Balasan
-
06 Maret 2012 7:38
Hi Priyank,
Can we insert into multiple tables from a single select statement?
No, this is not possible. An INSERT statement can only target a single
table. You'll have to split the action out over multiple INSERT
statements to add data to all affected tables.
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis- Ditandai sebagai Jawaban oleh KJian_ 13 Maret 2012 2:45
-
31 Oktober 2012 7:20
Hi Priyank,
Can we insert into multiple tables from a single select statement?
No, this is not possible. An INSERT statement can only target a single
table. You'll have to split the action out over multiple INSERT
statements to add data to all affected tables.
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
How? Should I be using an inner join so the data stays related?Living it and loving it.