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 2005 Forums
 Transact-SQL (2005)
 FOR XML PATH('')

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2008-04-16 : 12:02:38
Greetings

When using sp_xml_preparedocument @hdoc OUTPUT, @doc I see code everywhere with huge xml text embedded in some store procedures. Can the
SELECT XXX
FROM XXX
FOR XML PATH('') syntax be used instead to produce the second parameter @doc (xmltext) for sp_xml_preparedocument ?

Thanks

nathans
Aged Yak Warrior

938 Posts

Posted - 2008-04-16 : 14:17:13
you can set the result of query to parameter of datatype xml like so:

declare @XML xml

select @XML = ( select XXX
from dbo.XXX
for xml auto, type
)


seems wrong to generate this XML, then pass it as string to preparedocument just so it can "prepare" the string as XML so you can leverage in your OPENXML query. In 2005 you can do away with this and go directly against the @XML param.


Nathan Skerl
Go to Top of Page
   

- Advertisement -