 |
| SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 1st, 2007, 11:26 PM
|
|
Registered User
|
|
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Error Inserting string containing (') and (,)
I tried inserting the following string "China, People's Republic of" using an INSERT INTO similar to this one:
INSERT INTO Table1 VALUES ('1', 'Test', 'China, People's Republic of')
but the (') and (,) interfere with the statement and I get an error message.
Can anyone tell me what I should use to qualify the value "China, People's Republic of" to make the statement work.
Hope this makes sense
I can't seem to find any help on the subject
Thanks in Advance
|
|

May 2nd, 2007, 01:36 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Dom55,
'China, People's Republic of' - Wrong usage
'China, People''s Republic of' - Correct usage.
' - is used to enclose char/varchar/nvarchar/text/ntext/datetime values when used in sql statements. You should be taking care of negating the ' that appears within the values using another '.
Cheers
_________________________
- Vijay G
Strive for Perfection
|
|

May 2nd, 2007, 01:41 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
|
|
replace (') with ('')
|
|

May 3rd, 2007, 04:39 PM
|
|
Registered User
|
|
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you for the 3 replies. The solution you provided worked perfectly.
Thank you very much.
Domininc
|
|

May 9th, 2007, 04:57 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
another option
change
INSERT INTO Table1 VALUES ('1', 'Test', 'China, People's Republic of')
to
INSERT INTO Table1 VALUES ('1', 'Test', 'China, People''s Republic of')
but changing the people's with people''s it tells sql that it is data and not a field terminator.
|
|

June 1st, 2007, 03:31 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
|
|
The replace is done with two single quotes ('') and not one double quote (").
|
|
 |