0

I have two tables table A and table B.

I insert values in both table like this:

Insert Into A (Col1, Col2) Values ("1" "ABC")
Insert Into B (Col1, Col2) Values ("1" "ABC")

but, I want to perform this operation using single insert statement. I used Microsoft SQL Server Management Studio 2008 R2 for this.

Can anyone please tell me is it possible?

Thanks...!!!

4

2 回答 2

1

当且仅当列名相同时,您可以通过参数传递表名:

Insert Into @tableName (Col1, Col2) Values ("1" "ABC")
于 2013-09-30T05:34:19.027 回答
1

据我所知,单个查询是不可能的。但是您可以尝试使用带有两个插入语句的过程。或者尝试插入后触发器。

于 2013-09-30T05:42:58.097 回答