我关注此帖:SQL: INSERT INTO...VALUES..SELECT
我的qustion是如何声明从SELECT语句赋值的临时@ value1?我有类似
的东西CREATE PROCEDURE name
(
@arg1 as type1,
@arg2 as type2
)
AS
@value1 = SELECT x from tabley WHERE <something>
INSERT INTO Table(x,y,z) VALUES(@arg1,@arg2,@value1)
但我不知道在哪里声明并设置@ value1 ??
答案 0 :(得分:1)
CREATE PROCEDURE name
(
@arg1 as type1,
@arg2 as type2
)
AS
DECLARE @value1 as type1
SELECT @value1=x from tabley WHERE <something>
INSERT INTO Table(x,y,z) VALUES(@arg1,@arg2,@value1)
答案 1 :(得分:0)
SELECT @value1 := x from tabley WHERE <something>
答案 2 :(得分:0)
DECLARE @value1 as type = (SELECT ...)
取代你的陈述