﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / Getting Output value from sp_executesql for XML issue / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 17:31:59 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Getting Output value from sp_executesql for XML issue</title><link>http://www.sqlservercentral.com/Forums/Topic1379087-338-1.aspx</link><description>No need to be embarrassed and you're welcome.You'd be surprised how often the simplest issue is uncovered quickly by a second set of eyes.  In this case, I happened to have done a lot of dynamic SQL of late so the answer kind of jumped out at me.And it helped a lot to have code that was easily modified to run on my SQL.</description><pubDate>Wed, 31 Oct 2012 19:45:20 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Getting Output value from sp_executesql for XML issue</title><link>http://www.sqlservercentral.com/Forums/Topic1379087-338-1.aspx</link><description>Thanks so much. Its embarrassing, thats so simple. I couldn't see the wood for the trees :blush:</description><pubDate>Wed, 31 Oct 2012 19:41:24 GMT</pubDate><dc:creator>phil.layzell</dc:creator></item><item><title>RE: Getting Output value from sp_executesql for XML issue</title><link>http://www.sqlservercentral.com/Forums/Topic1379087-338-1.aspx</link><description>Try this:[code="sql"]DECLARE @tApplXML XML ,@SQL NVARCHAR(max),@ParmDefinition NVARCHAR(1024) ,@applnbr intset @applnbr = 24 SET @SQL = N'SELECT @ptApplXML = (SELECT * FROM [database].[dbo].[table] WHERE [ApplNbr] = @pApplNbr FOR XML PATH(''database.table''))'SET @ParmDefinition = N'@pApplNbr INT,@ptApplXML xml OUTPUT'PRINT @SQLEXECUTE sp_executeSQL @SQL,@ParmDefinition,@pApplNbr = @ApplNbr,@ptApplXML= @tApplXML OUTPUT select @tApplXML[/code]</description><pubDate>Wed, 31 Oct 2012 19:25:11 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>Getting Output value from sp_executesql for XML issue</title><link>http://www.sqlservercentral.com/Forums/Topic1379087-338-1.aspx</link><description>Hi,I am trying to get an xml blob into a var from dynamic sql. However, whenever I run this: DECLARE @tApplXML  XML			,@SQL               NVARCHAR(max),@ParmDefinition    NVARCHAR(1024) ,@applnbr intset @applnbr = 24         SET @SQL            =      N'SELECT * FROM [database].[dbo].[table] 					       WHERE [ApplNbr] =  @pApplNbr					       FOR XML PATH(''database.table'')'SET @ParmDefinition =      N'@pApplNbr INT,@ptApplXML xml OUTPUT'EXECUTE sp_executeSQL      @SQL,@ParmDefinition,@pApplNbr = @ApplNbr,@ptApplXML= @tApplXML OUTPUT    select @tApplXMLFirstly I get the XML returned from the OUTPUT , then I get a NULL value. I need @tApplXML to retain the XML value. But whatever I try I cant seem to get it to work.... :pinch:Can anyone point me in the right direction?Many thanks, Phil </description><pubDate>Tue, 30 Oct 2012 17:13:24 GMT</pubDate><dc:creator>phil.layzell</dc:creator></item></channel></rss>