我想用从“exec(字符串)”返回的内容分配一个变量,但在语法上遇到了困难。下面是一些工作代码...
declare @iGeographyLevel int = 2
declare @iGeographyLevelID int = 64
declare @sGeographyName varchar(30)
declare @sSQL nvarchar(max)
set @sSQL = '
select Name
from GeographyLevel'+ cast(@iGeographyLevel as varchar(5))+'
where GeographyLevel'+ cast(@iGeographyLevel as varchar(5)) + 'ID = '+ cast(@iGeographyLevelID as varchar(5))
exec (@sSQL)
我想做类似...
set @sGeographyName = exec (@sSQL)