dbTalk Databases Forums  

Creating txt file with diferent name every time from ssis

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Creating txt file with diferent name every time from ssis in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Spider Jerusalem
 
Posts: n/a

Default Creating txt file with diferent name every time from ssis - 09-24-2009 , 02:14 AM






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

Reply With Quote
  #2  
Old   
Todd C
 
Posts: n/a

Default RE: Creating txt file with diferent name every time from ssis - 09-24-2009 , 08:04 AM






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


"Spider Jerusalem" wrote:

Quote:
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

Reply With Quote
  #3  
Old   
Spider Jerusalem
 
Posts: n/a

Default Re: Creating txt file with diferent name every time from ssis - 09-24-2009 , 09:06 AM



Thanks

On Thu, 24 Sep 2009 06:04:03 -0700, Todd C
<ToddC (AT) discussions (DOT) microsoft.com> wrote:

Quote:
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


"Spider Jerusalem" wrote:

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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.