0
我得到的錯誤,當我通過此查詢到我的PROC即執行動態SQL:「獲取預期條件的上下文中指定的非布爾類型的表達式」錯誤與我的查詢?
"select @display = @display + gp2.ProblemDesc + ''|' '
from (SELECT gp.GrantProblemID, gp.ProblemDesc, gps.GrantProblemStatus, row_number() over (partition by gp.grantproblemid order by p.periodid desc) ranking
from MergedProgressReport.dbo.[PeriodAgencyGrantProblems] pagp
inner join MergedProgressReport.dbo.PeriodAgencyGrants pag on pag.PeriodAgencyGrantsID = pagp.PeriodAgencyGrantID
and pag.GrantNumber = ''2011UMWX0001''
inner join MergedProgressReport.dbo.periodagencyinfo pai on pag.PeriodAgencyInfoID = pai.PeriodAgencyInfoID
inner join MergedProgressReport.dbo.Periods p on p.PeriodID = pai.PeriodID
inner join MergedProgressReport.dbo.GrantProblemStatus gps on pagp.GrantProblemStatusID = gps.GrantProblemStatusID
inner join MergedProgressReport.dbo.GrantProblems gp on pagp.GrantProblemID = gp.GrantProblemID
and gp.GrantProblemAreaID = 7) xx right join MergedProgressReport.dbo.GrantProblems gp2 on xx.GrantProblemID = gp2.GrantProblemID and xx.ranking = 1
where gp2.GrantProblemAreaID = 7 "
我PROC:
CREATE proc [dbo].[Review_Get_PrePopValue](@sqlQuery nvarchar(500), @display nvarchar(200) OUTPUT)
as
EXEC sp_executesql @sqlQuery,
N'@display varchar(200) output',
@display = @display output