Solved

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

Posted on 2007-11-30
3
3,685 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

863 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now