October 6, 2009 at 3:20 am
is there a way where i can using "for xml" to create a query which will give me xml, and i will be able to store it in a varibale like @xmlstr a nvarchar(1000)?
Thanks
Peleg
October 6, 2009 at 1:18 pm
Simple answer: yes.
Example (using AdventureWorks):
DECLARE @xmlstr nvarchar(1000)
SET @xmlstr =
(SELECT top 1 *
FROM HumanResources.Shift
FOR xml auto, elements)
SELECT @xmlstr
/*Result set (reformatted manually):
<HumanResources.Shift>
<ShiftID>1</ShiftID>
<Name>Day</Name>
<StartTime>1900-01-01T07:00:00</StartTime>
<EndTime>1900-01-01T15:00:00</EndTime>
<ModifiedDate>1998-06-01T00:00:00</ModifiedDate>
</HumanResources.Shift> */
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply