Re: Select Aggregate out of Stored Proc
- From: "Pawel Potasinski" <pawel.potasinski@xxxxxxxxx>
- Date: Wed, 22 Aug 2007 15:23:56 +0200
Maybe this simple code can help (you need Notrhwind sample database to
execute the code):
USE Northwind
GO
CREATE PROC dbo.uspReturnEmployeesXML2
@doc XML OUT
AS
SET @doc =
(SELECT
EmployeeID,
FirstName,
LastName
FROM dbo.Employees Employee
FOR XML AUTO, ELEMENTS, ROOT('root'), TYPE)
GO
-- Execute this procedure and count employees
DECLARE @doc XML
EXEC dbo.uspReturnEmployeesXML2 @doc OUT
SELECT count(*) AS [Number of employees]
FROM @doc.nodes('/root/Employee/EmployeeID[1]') AS T(c)
It seems you can not simply pass xml just by selecting and not using output
parameter.
--
Regards
Pawel Potasinski
[http://www.potasinski.pl]
U¿ytkownik "Michael Morse" <MichaelMorse@xxxxxxxxxxxxxxxxxxxxxxxxx> napisa³
w wiadomo¶ci news:815B18B7-5FD3-4FC6-96A8-E674B69E6C0F@xxxxxxxxxxxxxxxx
Hi All,
I have a stored proc that returns an xml document using a query with XML
EXPLICIT. What I would like to do is something like this:
select Count(/root/Employee/EmployeID) from exec MyProcName. Is there a
way
to do this? My proc returns excellent detail data but I would like to get
summary data out of it.
Thanks for the help.
.
- Prev by Date: Re: internal binary objects in XML document
- Next by Date: Re: internal binary objects in XML document
- Previous by thread: Re: internal binary objects in XML document
- Next by thread: X12/EDI and XML
- Index(es):
Relevant Pages
|