January 21, 2010 at 2:53 am
Hi,
I have to migrate some data of a SQL table to XML. Now I have to convert a table column of type bit to a XML element of type Boolean.
|IsSet|
1
0
to
<root>
<IsSet>True</IsSet>
<IsSet>False</IsSet>
</root>
How can I achieve this?
Regards,
Andreas
January 21, 2010 at 12:48 pm
Would something like the following code do the job?
DECLARE @t TABLE (IsSet bit)
INSERT INTO @t SELECT 1 UNION ALL SELECT 0
SELECT
CASE WHEN IsSet=0 THEN 'False' ELSE 'True' END AS IsSet
FROM @t
FOR XML PATH(''), TYPE, ELEMENTS, ROOT('root')
/* result set:
<root>
<IsSet>True</IsSet>
<IsSet>False</IsSet>
</root>
*/
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy