标签:and lang join map sel people 形参 number nvarchar
@indexCt int
@DemographicName nvarchar(500)
INSERT INTO #finalTemp
EXEC(‘SELECT a.QuestionId,a.AnswerId, b.Name QuestionName,c.Name OptionName,a.Content,‘+@indexCt+‘ Number,‘‘‘+@DemographicName+‘‘‘ DemographicName FROM dbo.QuestionaireOther_‘+@questionaireId+‘ a
LEFT JOIN dbo.SVSpecQuestionsLanguage b
ON a.QuestionId=b.QuestionID
LEFT JOIN dbo.SVSpecQuestionOptionsLanguage c
ON a.AnswerId=c.OptionID
WHERE a.questionType=2 AND b.LanguageType=‘+@languageId+‘ AND c.LanguageType=‘+@languageId+‘
AND a.PeopleCode IN(SELECT peoplecode FROM dbo.Demographic_‘+@projectId+‘ WHERE ‘+@whe+‘ )‘)
整形参数 加一个‘‘
字符串 加三个‘‘‘ ‘‘‘
declare @projectid int
INSERT INTO #CrossNodeFinal
SELECT demoid,
demoname,
‘SELECT PersonGuid FROM dbo.SVEmployeeDemographicMapping WHERE ProjectId =@projectid AND CHARINDEX(‘‘,‘‘+CONVERT(NVARCHAR(50),DemographicID)+‘‘,‘‘,‘‘,‘
+ childlist + ‘,‘‘) >0 ‘,
demoname,
1
FROM #CrossRoot
WHERE rootid =
(
SELECT rootId FROM #RootId WHERE tmpId = 1
);
EXEC sp_executesql @whe, N‘@projectid int‘, @projectid;
exec 动态脚本 里面的参数和sp_executesql (注意引号,否则容易异常)
标签:and lang join map sel people 形参 number nvarchar
原文地址:https://www.cnblogs.com/jayblog/p/9317816.html