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.
| Author |
Topic |
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-08-21 : 10:29:53
|
Hi, I have this statement:EXEC MASTER..XP_CMDSHELL 'sqlcmd -Usa -Ppass -dtest -h-1 -Q"set nocount on select distinct name from table where state = 'Available'" -oC:\temp\folder\registry.txt' This above statement will be executed on the cmd line when I call the .sql file that ecompases it.As you can see, the 'Available' condition appears to be unquoted due to the required single Quotes of xp_cmdshell.Any idea how to work around this?Thanks--------------------------Joins are what RDBMS's do for a living |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-08-21 : 10:38:07
|
| EXEC MASTER..XP_CMDSHELL 'sqlcmd -Usa -Ppass -dtest -h-1 -Q"set nocount on select distinct name from table where state = ''Available''" -oC:\temp\folder\registry.txt' |
 |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-08-21 : 10:50:26
|
robvolk Thanks a lot, it does work when I executed the whole command.I'm just curious why when I exclude the following select It does not work:select distinct name from table where state = "Available" can you please give a little explaination?Thanks,--------------------------Joins are what RDBMS's do for a living |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-21 : 11:18:55
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|