Forum: Ruby Re: Uploading data to MS SQL Server - problem with quote cha

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Warren B. (Guest)
on 2006-01-05 03:42
(Received via mailing list)
Sam,

> I need to upload data coming from Oracle database to
> an MS SQL Server.  But I'm having problems inserting
> if data contains a quote (') character.

    On most all modern databases, a single quote must be quoted with
another single quote.  For example, to update a value to the string "I
don't know":

UPDATE mytable SET mystring = 'I don''t know.'

    I hope this helps.

    - Warren B.
Kevin B. (Guest)
on 2006-01-06 08:19
(Received via mailing list)
On Wednesday 04 January 2006 19:41, Warren B. wrote:
> UPDATE mytable SET mystring = 'I don''t know.'
>
>     I hope this helps.
>
>     - Warren B.

You'll also want to escape the usual SQL special characters, namely
backslashes etc if this stuff occurs in your data.  It's an SQL thing,
not a
Ruby thing though. :-)
This topic is locked and can not be replied to.