Discussion:
Creating txt file with diferent name every time from ssis
(too old to reply)
Spider Jerusalem
2009-09-24 07:14:15 UTC
Permalink
Hi,
I need to export data from sql table in txt file in same folder with
name of the file which is constant in first part ( like 'test.'), and
after test. every time diferent (It can be icremental number like
test.1, test.2, test.3...).
Is it possible

Dubravko
Todd C
2009-09-24 13:04:03 UTC
Permalink
Hello,
Yes this is possible. You will need to use an Expression in the Connection
String property of the flat file Connection Manager.

Do this:

* Click on the Flat File Connection Manager for the text file
* In the Properties panel, look for Expressions. Click the elipsis (...) in
the empty box next to it.
* In the dialog box, select Connection String from the list, then click the
elipsis again next to that. This will bring up the Expression Editor.
* Enter a value for the file location using variables, string literals,
and/or functions.

For example:
"\\\\MyServer\\MyShare\\MyFolder\\" + @[User::FileName] + ".txt"

will incorporate the User variable FileName into the ConnectionString. Note
that the backslash character \ is reserved so must be 'escaped' by putting
the special escaping character in front of it, which just happens to be the
backslash character. Hence the double \\.

To put a Date Stamp in the file name, I typically use something like this:

@[User::Logging_Folder] + @[System::MachineName] + "_" +
@[System::PackageName] + "_Exec_" +
(DT_STR, 8, 1252) ( YEAR(GETDATE()) * 10000 + MONTH( GETDATE() ) * 100 +
DAY(GETDATE())) + ".txt"

When you think you have it right, use the Evaluate Expression button so see
what it would look like. Keep in mind that values can and will change from
design time to run-time.

HTH
=====
Todd C
Post by Spider Jerusalem
Hi,
I need to export data from sql table in txt file in same folder with
name of the file which is constant in first part ( like 'test.'), and
after test. every time diferent (It can be icremental number like
test.1, test.2, test.3...).
Is it possible
Dubravko
Spider Jerusalem
2009-09-24 14:06:11 UTC
Permalink
Thanks

On Thu, 24 Sep 2009 06:04:03 -0700, Todd C
Post by Todd C
Hello,
Yes this is possible. You will need to use an Expression in the Connection
String property of the flat file Connection Manager.
* Click on the Flat File Connection Manager for the text file
* In the Properties panel, look for Expressions. Click the elipsis (...) in
the empty box next to it.
* In the dialog box, select Connection String from the list, then click the
elipsis again next to that. This will bring up the Expression Editor.
* Enter a value for the file location using variables, string literals,
and/or functions.
will incorporate the User variable FileName into the ConnectionString. Note
that the backslash character \ is reserved so must be 'escaped' by putting
the special escaping character in front of it, which just happens to be the
backslash character. Hence the double \\.
@[User::Logging_Folder] + @[System::MachineName] + "_" +
@[System::PackageName] + "_Exec_" +
(DT_STR, 8, 1252) ( YEAR(GETDATE()) * 10000 + MONTH( GETDATE() ) * 100 +
DAY(GETDATE())) + ".txt"
When you think you have it right, use the Evaluate Expression button so see
what it would look like. Keep in mind that values can and will change from
design time to run-time.
HTH
=====
Todd C
Post by Spider Jerusalem
Hi,
I need to export data from sql table in txt file in same folder with
name of the file which is constant in first part ( like 'test.'), and
after test. every time diferent (It can be icremental number like
test.1, test.2, test.3...).
Is it possible
Dubravko
Loading...