这对大多数人来说可能是微不足道的,但我并没有长时间(仅6个月)编写存储过程。我希望能够根据用于INSERT查询的列之一设置变量@testid。我怎样才能做到这一点?从INSERT查询中存储SQL变量FROM子句结果列
DECLARE @testid INT;
INSERT INTO [exporttestresultreport] (
[testid],
[othercolumn]
)
SELECT
[testid], -- <======= how can I set my variable based on this column?
[othercolumn]
FROM
[exporttestresultreport] e
WHERE
[exporttestresultreportid] = @exporttestresultreportid
@Mr。 MacGyver:任何理由不接受这个*较老的答案? – gbn
如果你改正你的语法,我会将它标记为答案。这就是我选择其他家伙的原因。我怎样才能结合这些查询? – MacGyver
@Mr。 MacGyver:你得到了什么错误? – gbn