Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting Data to a textfile with a dynamic filename.

Status
Not open for further replies.

knabet

IS-IT--Management
Jan 17, 2001
2
0
0
US
I need to dump data from a table to a comma delimted text file. I can do that.. the question is can I do it to a textfile with today's date in the filename.

For example would like to have the filename be
1-17-2001.csv and at 12:30am when the DTS runs the new filename would be 1-18-2001.csv ( the format of the date may not be exactly this, but should be able to change that at anytime )

I've completed this task by basically using a .bat file to rename the file once its created. But that involves 2 schedules and not using SQL Server to do it all which I'd like to do.

Thanks in advance for any help.
 

within a stored proc:

use 'bcp' out... then create a variable @currdate-(representing its filename); you might as well implement the dateadd function (to increment date in filename).

avn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top