简单SQL问题求助!!!1
declare @SQL nvarchar(4000)
declare @Number int
set @SQL = '
select count(*) from
interview I
Inner Join Job_Status J With (NoLock) On J.AccountID=I.AccountID And J.JobID=I.InterviewJobID
where I.AccountID = 1000000 and I.CandidateID = 10000 and J.DeptID in(1,2,3) '
exec(@SQL)
请问如何可以将上面执行@SQL后的结果赋值到@Number上啊!!1
------解决方案--------------------declare @SQL nvarchar(4000)
declare @Number int
set @SQL = '
select @Number=count(*) from
interview I
Inner Join Job_Status J With (NoLock) On J.AccountID=I.AccountID And J.JobID=I.InterviewJobID
where I.AccountID = 1000000 and I.CandidateID = 10000 and J.DeptID in(1,2,3) '
exec sp_executesql @SQL,N '@Number int output ',@Number output
print @Number