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 query results to CSV with dynamic filename

Author  Topic 

BogeyGrinder
Starting Member

6 Posts

Posted - 2011-07-01 : 09:08:18
I apologize if this isn't the correct forum. Please let me know the proper place to post if this isn't correct.

I need to execute a query each day and output the results to a CSV file. The filename of the CSV needs to have a very specific format: MMDDYYYY.csv.

I realize I can right-click my database in Management Studio and click Export.. then save that package. I can then schedule that package as a job, but I can't figure out how to make the output file name dynamic based on today's date.

I would prefer to have this set up as a scheduled job in Mgmt Studio so we can easily monitor the results.

Any tips?

BogeyGrinder
Starting Member

6 Posts

Posted - 2011-07-01 : 09:14:09
Edit.. figured out I can easily create a dynamic filename for BCP and use xp_cmdshell ... just curious how others may do it.
Go to Top of Page
   

- Advertisement -