Hi friends,
I am trying to export the contents of a table to a csv file. I have tried the following code but cannot find out what I'm doing wrong.
declare @sql varchar(8000)
select @sql = 'bcp travelcatdata.dbo.communicator out
''c:\datafiles\comm.txt'' -c -t, -T -S '+ @@servername
exec master..xp_cmdshell @sql
The file is not created and when I run the query I get the following in the results pane:
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"] [-x generate xml format file]
NULL
Can anyone help please?
Preferably I would like to export the results of a stored procedure accepting parameters but a table would also do fine.