September 4, 2007 at 9:04 am
declare
@sql varchar(8000)
select
@sql = 'bcp ORLANDO..(select * from vwEmpReport) out
c:\bcp\report.csv -c -t, -T -S'
+ @@servername
exec
master..xp_cmdshell @sql
when i run this query csv file is not created. why?
September 4, 2007 at 12:20 pm
Print the value of @sql, and run it from the command line, and you should have your answer.
September 4, 2007 at 4:22 pm
TRY changing @sql to
select @sql = 'bcp "select * from ORLANDO..vwEmpReport" queryout
c:\bcp\report.csv -c -t, -T -S'+ @@servername
* Noel
September 5, 2007 at 7:42 am
I get this as output
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
with message
(12 row(s) affected)
but i dont see any file in my folder
September 5, 2007 at 2:54 pm
Um, try space after -S in -S' +@@ ie:
select @sql = 'bcp "select * from ORLANDO..vwEmpReport" queryout
c:\bcp\report.csv -c -t, -T -S'+ @@servername
CHANGES TO:
select @sql = 'bcp "select * from ORLANDO..vwEmpReport" queryout
c:\bcp\report.csv -c -t, -T -S '+ @@servername
So long, and thanks for all the fishpaste 😉
September 5, 2007 at 6:06 pm
select @sql = 'bcp ORLANDO..vwEmpReport out
c:\bcp\report.csv -c -t, -T -S'+ @@servername
_____________
Code for TallyGenerator
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply