1

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
4

2 に答える 2

1

これを使って -

declare @foo int
declare @bar int
select @foo=foo, @bar=bar from Foobar where id=123;

insert into ...
select @foo, 3, @bar
于 2013-02-19T17:27:16.757 に答える
1

次を使用して変数を割り当てることができますSELECT

select @foo=foo, @bar=bar from Foobar where id=123;

または、変数をスキップして と を組み合わせSELECTますINSERT

insert into ...
select foo, bar
from Foobar
where id = 123;
于 2013-02-19T17:27:31.523 に答える