Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to insert string with a comma in a varchar?

Author  Topic 

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2011-01-21 : 16:12:54
Hi All,

I have a table called CompetitorMapping with a column RDS_CompetitorAddress with nvarchar(255) data type. I need to insert strings in this column that has comma (,). So how I do insert the following string in this table.

KENT,WA-10201 SE 240th

Thanks for the prompt help.

Zee

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-21 : 16:13:57
Ummm, just like you would any other data.

INSERT INTO ...
VALUES (1, 'abcdefg,asdfj;dsfa,21343,sadflkjaf', ...)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2011-01-21 : 16:21:21
Sorry. Here is the correct string. How do I insert the following string? Please suggest. Thanks.

KENT'WA-10201 SE 240th

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-21 : 16:24:47
Well that's not a comma. That's a single quote. You'll need to escape it.

'KENT''WA-10201 SE 240th'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -