34,587
社区成员
发帖
与我相关
我的任务
分享
declare @Products table (id INT IDENTITY,Bid int,name varchar(4))
insert into @Products
select 2,'小王' union all
select 2,'小猫' union all
select 2,'小A' union all
select 2,'小B'
INSERT INTO @Products(Bid,name) select 3,name from @Products WHERE Bid=2
SELECT * FROM @Products
/*
id Bid name
----------- ----------- ----
1 2 小王
2 2 小猫
3 2 小A
4 2 小B
5 3 小王
6 3 小猫
7 3 小A
8 3 小B
*/
insert into Products(bid,name)
select 3,name from Products where Bid=2