Dynamic Flat File Destination with a Variable in SSIS

A nice little code snippet for your cookbook 🙂

In case you would like to export data via SSIS to a dynamic Flat File Destination (which includes the current date and time), like for example:

C:\Temp\CSV-File-Example-201309061121.csv

You might want to use this expression for a Variable value or directly for your ConnectionString (Flat File Connection):


"C:\\Temp\\CSV-File-Example-" +
(DT_STR,4,1252) DatePart("Year",getdate()) +
Right("0" + (DT_STR,4,1252) DatePart("Month",getdate()),2) +
Right("0" + (DT_STR,4,1252) DatePart("Day",getdate()),2) +
Right("0" + (DT_STR,4,1252) DatePart("Hour",getdate()),2) +
Right("0" + (DT_STR,4,1252) DatePart("Minute",getdate()),2) + ".csv"

SSIS-Dynamic-Flat-File-Destination-FileName

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s