mdward4
asked on
bcp error usage: bcp {dbtable | query} {in | out | queryout | format} datafile
I am trying to write a procedure for Sql 2005 to export the results of a query to a flat file. I keep receiving the error -
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]
here is the code:
declare @sql varchar(8000)
select @sql = 'bcp "select stockid from stock"
queryout c:\upload_pics\testshawn.t xt -T -S server\instance -U <user> -P <password> '
exec master..xp_cmdshell @sql
I can not seem to find what I am doing wrong.
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]
here is the code:
declare @sql varchar(8000)
select @sql = 'bcp "select stockid from stock"
queryout c:\upload_pics\testshawn.t
exec master..xp_cmdshell @sql
I can not seem to find what I am doing wrong.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got the procedure to work.
Open in new window