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)
 Update to Ntext column

Author  Topic 

ljp099
Yak Posting Veteran

79 Posts

Posted - 2009-09-16 : 15:40:12
I need to update an ntext column with a large block of data that contains apostrophes and double quotes. What can I do easily make the update query work - the apostrophes and double and single quotes wont allow me to execute the update.

For example:

Update xml_tbl set content =

<td valign="top">Does this research discuss or present Global Solutions?<br />
<input xml:space="default" id="DiscussGlobalSolutions" title="Global Solutions" type="checkbox" disabled="disabled">
<xsl:if test="/root/DocInfo/DiscussGlobalSolutions='true' or /root/DocInfo/DiscussGlobalSolutions='1'">
<xsl:attribute name="checked">checked</xsl:attribute>

where id = 24

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-09-16 : 15:46:04
double quotes won't be a problem but the single quotes (apostrophes) need to escaped with another single quote. So in other words replace a single quote with 2 single quotes:

'<td valign="top">Does this research discuss or present Global Solutions?<br />
<input xml:space="default" id="DiscussGlobalSolutions" title="Global Solutions" type="checkbox" disabled="disabled">
<xsl:if test="/root/DocInfo/DiscussGlobalSolutions=''true'' or /root/DocInfo/DiscussGlobalSolutions=''1''">
<xsl:attribute name="checked">checked</xsl:attribute>'

Be One with the Optimizer
TG
Go to Top of Page

ljp099
Yak Posting Veteran

79 Posts

Posted - 2009-09-16 : 16:42:51
So there is no easy way to move ntext data from one column to another? Couldnt I do a paramertized query to select the data I need, and then take it and insert it into the column I want to update?
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-09-16 : 17:56:49
If it is already in a sql server column and you simply want to "move" it to another table/column then it should be as simple as: set col2 = col1.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -