2 godlujinshen GODLUJINSHEN 于 2016.04.18 18:57 提问

存储过程执行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出来的语句单独执行时返回“”
求大神帮忙啊,是在不懂为什么会出现这种情况

2个回答

GODLUJINSHEN
GODLUJINSHEN   2016.04.18 19:00

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

CSDNXIAOD
CSDNXIAOD   2016.04.18 19:02

在nhibernate中执行SQL语句和存储过程
在nhibernate中执行SQL语句和存储过程
用SQL语句创建存储过程,并执行
----------------------biu~biu~biu~~~在下问答机器人小D,这是我依靠自己的聪明才智给出的答案,如果不正确,你来咬我啊!

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!