这对你们大多数人来说可能是微不足道的,但我已经很久没有编写存储过程了(仅 6 个月)。我希望能够根据用于 INSERT 查询的列之一设置变量 @testid。我怎样才能做到这一点?
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