更新时间:2022-05-23 21:39:43
如果我理解你的问题,你可以将作业放在SELECT中
子句。请考虑以下示例
If I understand your question correctly, you can place the assignment inside theSELECT
clause. Consider the following example
DECLARE @name varchar(10)
DECLARE @id int;
SELECT @name = s.name,
@id = s.id
FROM sysobjects s
WHERE s.id = (SELECT max(a.id) FROM sysobjects a)
PRINT @name
PRINT @id