Solved

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

Posted on 2007-11-30
3
3,701 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

717 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