Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 convert varchar to xml
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vidhyashri
Starting Member

4 Posts

Posted - 10/12/2012 :  08:30:34  Show Profile  Reply with Quote
Hi ,

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

jimf
Flowing Fount of Yak Knowledge

USA
2875 Posts

Posted - 10/12/2012 :  08:48:32  Show Profile  Reply with Quote
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 - 10/12/2012 :  09:27:13  Show Profile  Reply with Quote
string value contains xml file content. xml file content contains single quote. so i cant able to convert .
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/12/2012 :  09:42:28  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000