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 |
|
kgundava
Yak Posting Veteran
66 Posts |
Posted - 2011-07-05 : 12:01:59
|
| Hi All,I have a scenario where i have to write the out put of a query to a file using OSQL. Unfortunately for me , I am stuck here i.e i am not figure out how to escape special in the table name DECLARE @CMDTEST VARCHAR(3000)SELECT @CMDTEST = 'osql -E -S -Q"select * from QA..SAPR3."\BDL\BADHOST" " -o"E:\TEST_QUERY_OUTPUT.txt"'print @CMDMINUSEXEC master..XP_cmdshell @CMDTESTThanks...This is the error it is writing into the output fileLevel 15, State 1, Server OPDEV, Line 1Incorrect syntax near '/BDL/BADHOST'.instead of \BDL\BADHOST if i give some other table name(i.e. without special characters) , the query is working fine |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-07-05 : 12:25:26
|
| Maybe-Q"select * from QA..SAPR3.[\BDL\BADHOST] "==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-07-05 : 12:26:29
|
If \BDL\BADHOST is really a table name then try[\BDL\BADHOST] No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
kgundava
Yak Posting Veteran
66 Posts |
Posted - 2011-07-05 : 14:45:09
|
| Thanks a ton --->nigelrivett,webfred !!!! It worked!!!! |
 |
|
|
|
|
|