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
 General SQL Server Forums
 New to SQL Server Programming
 convert varchar to xml

Author  Topic 

vidhyashri
Starting Member

4 Posts

Posted - 2012-10-12 : 08:30:34
Hi ,

I need to convert the string value into xml value. need of query to execute it.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-10-12 : 08:48:32
select convert(xml, yourstring)

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

vidhyashri
Starting Member

4 Posts

Posted - 2012-10-12 : 09:27:13
string value contains xml file content. xml file content contains single quote. so i cant able to convert .
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-12 : 09:42:28
quote:
Originally posted by vidhyashri

string value contains xml file content. xml file content contains single quote. so i cant able to convert .

Can you post sample data? Are you trying to convert a string, or import a file? If you are trying to import a file, is the data in the file plain strings, or is it xml with tags? In any case, here is an example of how you can convert even with single quotes. However, if you have special characters such as <,>, & etc., this will not work.
DECLARE @x XML; SET @x = 'abcd''qure';
SELECT CAST(@x AS XML);
Go to Top of Page
   

- Advertisement -