Friday, March 30, 2012

Saving text to MS-SQL...

If you use the command UPDATE <tablename> SET <fieldname> = ' ... ' to
update a CHAR or TEXT field there are some characters that can cause
problems such as a single quote. Are there any other type of charaters like
that?

TIA"The Eeediot" <eeediot@.hotmail.com> wrote in message
news:S-ydnff_Qu2V6cncRVn-gw@.giganews.com...
> If you use the command UPDATE <tablename> SET <fieldname> = ' ... ' to
> update a CHAR or TEXT field there are some characters that can cause
> problems such as a single quote. Are there any other type of charaters
> like
> that?
>
> TIA

Check out "Using char and varchar Data" in Books Online.

The single quote is only an issue because it's the MSSQL string terminator,
so it needs to be doubled to escape it. Apart from that, there shouldn't be
a problem unless you're storing characters which aren't available in the
collation for your column, or non-ASCII characters such as Arabic or
Chinese. If this is a concern, you can use nchar or ntext to store the data
as Unicode.

Simon

No comments:

Post a Comment