Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Export SQL Table to comma delimited CVS File

Author  Topic 

kenworld
Starting Member

1 Post

Posted - 2014-11-26 : 08:56:25
When I run my SQL Job it's not creating the file on my specified path.

Job

DECLARE @sql VARCHAR (8000);
SELECT @sql = bcp "SELECT * FROM LMP_DAILY.dbo.vw_DirDailyActual ORDER by Date, DirCode" out
-o "T:\Shared Information\DB_Admin\dirdailyactual.csv" -T -c';
exec master..xp_cmdshell @sql;

It returns the following:
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]

It looks like its a permission issue. I have write permissions to the folder that I'm trying to write too.


kenworld

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-11-27 : 16:06:23
can you try this

DECLARE @sql VARCHAR (8000);
SELECT @sql = 'bcp "SELECT * FROM LMP_DAILY.dbo.vw_DirDailyActual ORDER by Date, DirCode" queryout
T:\Shared Information\DB_Admin\dirdailyactual.csv -T -c';
exec master..xp_cmdshell @sql;

Javeed Ahmed
https://www.linkedin.com/pub/javeed-ahmed/25/5b/95
Go to Top of Page
   

- Advertisement -