"exec (string)"에서 반환되는 변수를 할당하고 싶지만 구문에 어려움을 겪고 있습니다. 다음은 몇 가지 작업 코드 ...SQL에서 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)
일부 사람들은 http://stackoverflow.com/questions/2245691/how-to-assign-an-exec-result-to-a-sql-variable의 복제본이라고 말할 수 있습니다. SP – Mead3000