How do I set multiple values before an insert statement? The below doesnt work.
declare @foo int
declare @bar int
set (select @foo=foo, @bar=bar from Foobar where id=123);
insert into ...
select @foo, 3, @bar
How do I set multiple values before an insert statement? The below doesnt work.
declare @foo int
declare @bar int
set (select @foo=foo, @bar=bar from Foobar where id=123);
insert into ...
select @foo, 3, @bar
これを使って -
declare @foo int
declare @bar int
select @foo=foo, @bar=bar from Foobar where id=123;
insert into ...
select @foo, 3, @bar
次を使用して変数を割り当てることができますSELECT
。
select @foo=foo, @bar=bar from Foobar where id=123;
または、変数をスキップして と を組み合わせSELECT
ますINSERT
。
insert into ...
select foo, bar
from Foobar
where id = 123;