| Author |
how to insert string into SQL server table with single quote
|
|
|
| Hi I am using VFP 9.0 and SQL server 2003. I need to insert O'Neal as
lastname into my table located on sql server throgh SQLEXEC command. Since
it has single quote I am getting error. how can I do it?
Thanks.
| |
|
| Would a variable substitution work?
i.e.
m.lname = "O'neill"
mcmd = 'Insert into tblXX (fldLastName) values (m.lname)'
Jack
"Sunny" <sunny_1178@hotmail.com> wrote in message
news:ey7JpV8iFHA.3256@TK2MSFTNGP12.phx.gbl...
> Hi I am using VFP 9.0 and SQL server 2003. I need to insert O'Neal as
> lastname into my table located on sql server throgh SQLEXEC command. Since
> it has single quote I am getting error. how can I do it?
>
> Thanks.
>
>
| |
| jndb72 2005-07-18, 1:24 pm |
|
Sunny wrote:
> Hi I am using VFP 9.0 and SQL server 2003. I need to insert O'Neal as
> lastname into my table located on sql server throgh SQLEXEC command. Since
> it has single quote I am getting error. how can I do it?
>
> Thanks.
Hi,
One way is to store the value to a variable.
LOCAL lcSql, lnRetVal
lcSql = "O'Neil"
lnRetVal = SQLEXEC(lnConnection
Handle, "INSERT INTO YourTable
(YourField) VALUES (?lcSql)")
hth
| |
| Olaf Doschke 2005-07-18, 1:24 pm |
| > I need to insert O'Neal
> on sql server
SQL server takes two single quotes as one:
O''Neil should work.
either
insert into mytable (name) values ('O''Neil')
or
insert into mytable (name) values ("O''Neil")
unsure about :
insert into mytable (name) values ("O'Neil")
Bye, Olaf.
| |
|
| Thanks everybody for quick response.
"Sunny" <sunny_1178@hotmail.com> wrote in message
news:ey7JpV8iFHA.3256@TK2MSFTNGP12.phx.gbl...
> Hi I am using VFP 9.0 and SQL server 2003. I need to insert O'Neal as
> lastname into my table located on sql server throgh SQLEXEC command. Since
> it has single quote I am getting error. how can I do it?
>
> Thanks.
>
>
|
|
|
|