Quote problem
- From: jhogan <jessehogan1976@xxxxxxxxx>
- Date: Tue, 24 Nov 2009 08:53:51 -0800 (PST)
This has probably been asked before but I can't seem to find this
anywhere.
Can someone help me understand what I am seeing.
Lets start a session on cygwin...
set -x
# set $t to some sql preceded by a -Q flag. This will be passed to
another command obviously.
$ t=" -Q \"SELECT curriculum_last_update FROM application_settings\" "
+ t=' -Q "SELECT curriculum_last_update FROM application_settings" '
# So far so good
$ echo $t
+ echo -Q '"SELECT' curriculum_last_update FROM
'application_settings"'
-Q "SELECT curriculum_last_update FROM application_settings"
Notice the single-quote at the end of SELECT and at the beginning of
application_settings. Why does that happen?
# Make a call to sqlcmd. sqlcmd is a command line interface to sql
server. $t now contains the SQL
# that I would like to run, preceded by -Q which means "query"
$ sqlcmd -b -x -d mydb -S myserver $t
+ sqlcmd -b -x -d mydb -S myserver -Q '"SELECT'
curriculum_last_update FROM 'application_settings"'
Sqlcmd: 'SELECT" curriculum_last_update FROM "application_settings
\""': Unexpected argument. Enter '-?' for help.
sqlcmd seems to be getting a sql string that has a couple of
unnecessary quotes (not even sure if they are double or single
according to the output".
Oh well, I would love to know why this is happening. Thanks for your
help in advance.
.
- Follow-Ups:
- Re: Quote problem
- From: Ben Finney
- Re: Quote problem
- From: Bill Marcum
- Re: Quote problem
- Prev by Date: Re: 2|3lines
- Next by Date: Re: 2|3lines
- Previous by thread: §§§ Cheap *** Chloe handbag and purse at WEBSITE: www.fjrjtrade.com (***)
- Next by thread: Re: Quote problem
- Index(es):