Hello, I am having trouble with my stored procedure. Any help would be appreciated.
I am passing parameters to a SP, inserting them into a temp table and then selecting all from the temp table to save to a text file.
Here is my code:
SET @UploadDir = '\\MyServer\testdata\'
SET @UploadFileName = 'vouchers.txt'
SET @SQL = ' bcp "' + 'Select * From #tmpCashAdvances"' + 'queryout ' + @UploadDir + @UploadFileName + ' -c -SDAISY -Usa -Psql'
EXEC master..xp_cmdshell @SQL
When I try to execute this SP from the Query Analzer I receive the following error message:
Copy direction must be either 'in', 'out' or 'format'.
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"]
NULL
I am passing parameters to a SP, inserting them into a temp table and then selecting all from the temp table to save to a text file.
Here is my code:
SET @UploadDir = '\\MyServer\testdata\'
SET @UploadFileName = 'vouchers.txt'
SET @SQL = ' bcp "' + 'Select * From #tmpCashAdvances"' + 'queryout ' + @UploadDir + @UploadFileName + ' -c -SDAISY -Usa -Psql'
EXEC master..xp_cmdshell @SQL
When I try to execute this SP from the Query Analzer I receive the following error message:
Copy direction must be either 'in', 'out' or 'format'.
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"]
NULL