Adding a ' in a sql statment
Posted in 2000
Topics: Data Types & Schema Design
I am trying to add the line "Rich's test" in a varchar field but I cannot add the '. How would I do this? I've tried "INSERT INTO testtable VALUES ('Rich\\'s test');" but that does not work. Ive even tried \\\\' and \\\\\\'. Any ideas? thanks, Richard Krenek
Try 'Rich''s test'. The secret is to double ' and " when needed. Richard Krenek (rkrenek@ihs.com) wrote: : I am trying to add the line "Rich's test" in a varchar field but I : cannot add the '. How would I do this? I've tried : "INSERT INTO testtable VALUES ('Rich\\'s test');" but that does not work. : Ive even tried \\\\' and \\\\\\'. Any ideas? : thanks, : Richard Krenek -- Rob Wilson rwilson@ntsource.com
Try two single quotes, as in: "INSERT INTO testtable VALUES ('Rich''s test');" "Richard Krenek" <rkrenek@ihs.com> wrote in message news:39649C40.31B0ABE1@ihs.com... > I am trying to add the line "Rich's test" in a varchar field but I > cannot add the '. How would I do this? I've tried > "INSERT INTO testtable VALUES ('Rich\\'s test');" but that does not work. > Ive even tried \\\\' and \\\\\\'. Any ideas? > > thanks, > Richard Krenek >
Richard Krenek <rkrenek@ihs.com> wrote in message
news:39649C40.31B0ABE1@ihs.com...
> I am trying to add the line "Rich's test" in a varchar field but I
> cannot add the '. How would I do this? I've tried
> "INSERT INTO testtable VALUES ('Rich\\'s test');" but that does not work.
> Ive even tried \\\\' and \\\\\\'. Any ideas?
>
> thanks,
> Richard Krenek
>
You can also add the value surrounded by double quotes as follows:
INSERT INTO testtable VALUES ("Rich's test");