I have stored the process of retrieving the XML I XML as a result of the return but not as a result of the result:
to create the process #xml_test as one xml go raw
I'm trying to put this XML in a variable:
Declare @xml as nvarchar (max)
but how can I not do it? My best idea was in the INSERT ... EXEC, but I get an error 'XML' clause is not allowed in 'INSERT statement'. ::
Create table # tmp (col1 nvarchar ( Max) tap faucet insert in #tmp exec #xml_test
This approach works well for normal text:
process # Select to create text_test Join #tmp exec #text_test as 'aaa'
I'm surprised that someone has given this issue before Hit the area? I am on SQL Server 2005
There are some examples of choosing from XML that are running on page:
What's new for XML in Microsoft SQL Server 2005
This is the simplest example:
DECLARE @ cust XML; SET @ cut = (XML Auto, choose from the type of customers)
Well, after an appropriate warning for a silly, ill-thought commentary, here's an answer I hope there is something better that it uses OPENROWSET to store the results of a stored procedure in a temporary table. From there, the result can be passed to a variable. This is a bit confusing, and requires server-level permission to enable ad-hoc distributed queries.
Anyway, there is a fully tested T-SQL:
Make database db_test; Go use [db_test]; Go as an option for XML RAW xml_test 'sp_configure' Show Advanced Options, 1; Reconfigure; Geo sp_configure 'ad hoc distributed query', 1; Reconfigure; Go to #tbl_test from OPENROWSET ('SQLNCLI', 'server = (local); trusted_connection = yes', 'set fmtonly off exec db_test.dbo.xml_test' as AS tbl_test; go DECLARE @ xml_test as XML; SET @xml_test = (SELECT, BINARY BASE64 from #tbl_test for XML Raw); Go
Comments
Post a Comment