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 2012 Forums
 Transact-SQL (2012)
 export to csv\txt

Author  Topic 

ori_davidson
Starting Member

15 Posts

Posted - 2014-09-17 : 03:21:05
hello,
is it possible to run a job\view that will export the data to a TXT or CSV file?
THNX,
ORI

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-09-17 : 05:03:27
Yes, you can do it by calling BCP or OPENROWSET into your stored procedure and then schedule the procedure from a job.

Javeed Ahmed
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2014-09-18 : 01:52:31
Another option is to use Powershell - and utilise the export-csv cmdlet. This will show you how to utilise the export-csv - you need to first generate the recordset - http://www.sqlserver-dba.com/2012/05/export-csv-powershell.html

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-18 : 09:32:21
...or use SSIS
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2014-10-02 : 01:49:21
If you're attempting BCP from within a stored procedure onsider SQL Server permissions to write under its user account and running as a service.

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -