要用查询中的值填充一个变量,我可以写下面的内容:
SET @TargetID = (SELECT TOP 1 ID FROM @bigDataSet ORDER BY date DESC)
要从此查询中填充多个变量,例如.就像是:
SET (@TargetID,@TargetName) = ....(SELECT TOP 1 ID,[Name] FROM @bigDataSet ORDER BY date DESC)
我能写什么
解决方法
SELECT TOP (1) @TargetID=ID,@TargetName=Name FROM @bigDataSet ORDER BY date DESC