拥有具有价值的表用户:
FirstName LastName Age
A A 20
B B 21
C C 22
D D 21
E E 20
有我从这个表中选择值的过程,然后想要排序并插入到另一个表中,我这样做:
SELECT @firstName = FirstName ,lastName = LastName ,@age = Age FROM dbo.users
if @age = 20
insert into tbl1(FirstName,LastName) values (@firstName,@LastName )
if @age = 21
insert into tbl2(FirstName,LastName) values (@firstName,@LastName )
if @age = 22
insert into tbl3(FirstName,LastName) values (@firstName,@LastName )
当我这样做时,所有行都不会插入到表中,我认为需要循环或其他东西来做,有人可以帮助我吗?我想在没有光标的情况下进行