I am running SQL Server 2000 and need to output query data to a text file.
If I run the following query (Below) using XP_CMDSHELL and BCP, it runs fine and creates a text file with the data output.
However, I need to change the WHERE Field1=10 to a string value WHERE Field1='abc'. When I try to do this I get a general error on the Field1='xyz'. I tried to change the quotes, etc but I am still getting the error. Any ideas?
Exec master..xp_cmdshell 'bcp "SELECT Field1 FROM Table WHERE Field1=10" queryout c:\filename.txt -U UserName -P Password /S SQLServerNam /c'