Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 using xml sproc data within another sproc

Author  Topic 

wannabeLordOftheCode
Starting Member

2 Posts

Posted - 2015-02-19 : 08:44:25
Create a sproc_2 to execute the previous xml sproc_1 that you have just created above. This new sproc_2 will accept the output from sproc_1 into a variable called @x. Shred this xml data in the @x variable into a temporary table using the xquery .value and .nodes methods

how do I reference the output of sproc 1 in my new sproc 2?

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2015-02-19 : 08:51:54
Pass it to sproc 2 as a parameter
Go to Top of Page

wannabeLordOftheCode
Starting Member

2 Posts

Posted - 2015-02-19 : 09:29:27
quote:
Originally posted by James K

Pass it to sproc 2 as a parameter



like this ?

Declare @x xml
='
<orders>
<c>
<FirstName>Christy</FirstName>
<LastName>Zhu</LastName>
<o>
<SalesOrderID>43701</SalesOrderID>
<OrderDate>2011-12-06T00:00:00</OrderDate>
<d>
<ProductID>871</ProductID>
<OrderQty>1</OrderQty>
</d>
</o>
</c>
<c>
<FirstName>Seth</FirstName>
<LastName>Phillips</LastName>
<o>
<SalesOrderID>51230</SalesOrderID>
<OrderDate>2003-07-04T00:00:00</OrderDate>
<d>
<ProductID>871</ProductID>
<OrderQty>1</OrderQty>
</d>
</o>
</c>
<c>
<FirstName>Evan</FirstName>
<LastName>James</LastName>
<o>
<SalesOrderID>52164</SalesOrderID>
<OrderDate>2003-08-07T00:00:00</OrderDate>
<d>
<ProductID>871</ProductID>
<OrderQty>1</OrderQty>
</d>
</o>
</c>
<c>

how do I add to a temporary table to shred the data?
Go to Top of Page

viggneshwar
Yak Posting Veteran

86 Posts

Posted - 2015-02-24 : 04:58:57
you can insert the stored procedure output to the tables like
insert into #temp
exec Sotred_Proceudre

The output of the stored procedure will be stored in the temporary table.

Regards
Viggneshwar A
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-02-25 : 04:21:09
since this is a homework question, you need to try to write the query yourself first. Use what you have learned and any text books/web sites that go with your course. Post your query here if it still doesn't work
Go to Top of Page
   

- Advertisement -