Solved

SQL Script - Insert comma separated values with a comma in value

Posted on 2007-11-30
3
3,693 Views
Last Modified: 2008-02-01
In the 5th value I am entering below, I actually want to enter the comma in the middle.  I want to enter this as the 5th value '''1900-01-01''','''0001-01-01'''.  Is there some kind of escape character I can use to enter that in the manner described?

insert into CMvCM2.dbo.LA_Analysis_Var_MICLGCDt values (
'score1',
29,'-29',
536870912,
'd.MICLGCDt',
'''1900-01-01''','''0001-01-01''',
'b.MICLGDt',
'''01-01-1900''')
0
Comment
Question by:donnatronious
3 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 20386178
You do not need to escape commas.
0
 
LVL 25

Accepted Solution

by:
imitchie earned 500 total points
ID: 20386635
insert into CMvCM2.dbo.LA_Analysis_Var_MICLGCDt values (
'score1',
29,'-29',
536870912,
'd.MICLGCDt',
'''1900-01-01'',''0001-01-01''',
'b.MICLGDt',
'''01-01-1900''')

I've removed two extraneous single quotes for you.  below is what it looks like (added spaces for clarity)
begin quote -- escaped quote --- escaped quote --- comma --- escaped quote ---- escaped quote ----- end quote
'   ''    1900-01-01''    ,     ''    0001-01-01    ''    '
0
 
LVL 5

Expert Comment

by:ursangel
ID: 20394405
Why dont you directly use the whole things inside a single quoted string
i didn get your reason for using it in this way.
'1900-01-01,0001-01-01'

if im wrong, please correct me
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question