存储过程执行SQL与Print SQL语句单独执行结果不同

代码如下:
DECLARE @SQLEX1 nVARCHAR(MAX)
DECLARE @TempEX1 VARCHAR(MAX)
SELECT @SQLEX1 = ''
SELECT @TempEX1 = ''
SET @SQLEX1 = 'SELECT @Temp3 = A.T FROM (SELECT T = REPLACE((SELECT DISTINCT ''20'' AS ''machine/@id1'',1 AS ''machine/@actionId''
FROM TEKIOUKISYU_適応機種 AS TK WHERE IUINDEX = ''' + @IUID +'''
AND MDPACKKATAMEI = '''+@MDPACKKATAMEI+''' AND ID3 = ''' + @Tekiouos
+ ''' FOR XML PATH(''machineSupport'')),''/>'',''/>''+ISNULL((SELECT DISTINCT ID AS ''@id'' FROM TEXTINFO
INNER JOIN (SELECT DISTINCT IUINDEX,MDPACKKATAMEI,BPQ20001000 AS BK FROM TEKIOUKISYU_適応機種
WHERE BPQ20001000 <> '''' AND ID3 = '''+@Tekiouos+''' AND MDPACKKATAMEI = '''+@MDPACKKATAMEI+''' AND IUINDEX = '''+@IUID+''' ) AS IPT
ON IPT.IUINDEX = TEXTINFO.IUINDEX AND IPT.MDPACKKATAMEI = TEXTINFO.MDPACKKATAMEI WHERE TEXTINFO.NAME LIKE ''[0-9]%''
AND RDBv6.dbo.findRegex(VALUE,CASE WHEN IPT.BK = '''' THEN ''#'' ELSE IPT.BK END,0) = 1 FOR XML PATH(''noteRef''),
ROOT(''noteRefs'')),''''))) A WHERE A.T LIKE ''%actionId%'''
print @SQLEX1
EXEC sp_executesql @SQLEX1,N'@Temp3 varchar(max) output',@TempEX1 output
该段代码嵌套在一个游标中,@SQLEX1返回值@Temp3在执行的sp_executesql时返回“”而使用Print出来的语句单独执行时返回“”
求大神帮忙啊,是在不懂为什么会出现这种情况

1个回答

求大神帮忙啊,求大神帮忙啊

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问