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
 SSIS and Import/Export (2005)
 Expressions and Date

Author  Topic 

jamie_pattison
Yak Posting Veteran

65 Posts

Posted - 2008-08-08 : 07:31:52
I have a flat file with a connector. I would like to run this app and it automatically saves the file to \\Server\Share$\ with a date and time of when the file was generated. So far i have aregular expression:

DT_WSTR,30)(GETDATE())

Which i found on the web, but not sure how to add the filename to be produced when this package runs and how to add the UNC path to it. Could someone advise please in a step by step format as im new to SSIS?

Thanks in advance

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-08-08 : 08:44:50
Hi jamie,

1. right click on connection manager for your flatfile
2. choose properties
3. click Expressions and then that little button [...]
4. in property expression editor choose ConnectionString in the Property Column
5. in Expression Column click [...]
6. Enter Expression like my example below
7. click Button [Evaluate Expression] to see it works
8. click ok
9. click ok
10. done

"\\\\servername\\shared$\\test_" + (DT_WSTR,4)YEAR(GETDATE()) + RIGHT("0" + (DT_WSTR,2)MONTH(GETUTCDATE()), 2) + RIGHT("0" + (DT_WSTR,2)DAY( GETUTCDATE()), 2) + RIGHT("0" + (DT_WSTR,2)DATEPART("hh", GETUTCDATE()), 2) + RIGHT("0" + (DT_WSTR,2)DATEPART("mi", GETUTCDATE()), 2) + RIGHT("0" + (DT_WSTR,2)DATEPART("ss", GETUTCDATE()), 2) + ".txt"

Webfred
Edit: Try to modify this example for your satisfaction!
Go to Top of Page

jamie_pattison
Yak Posting Veteran

65 Posts

Posted - 2008-08-08 : 08:52:37
Hello WebFred

I tried that and the expression works (thanks for that) BUT i receive the error:

TITLE: Package Validation Error
------------------------------

Package Validation Error

------------------------------
ADDITIONAL INFORMATION:

Error at Package [Connection manager "ffcmUATClaimCSV"]: The file name "\\servername\shared$\test_20080808125031.csv" specified in the connection was not valid.

Error at Package: Connection "ffcmMyNewFile" failed validation.

(Microsoft.DataTransformationServices.VsIntegration)

------------------------------
BUTTONS:

OK
------------------------------

When i run the application. Whats going wrong here?

Thanks
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-08-08 : 09:09:46
Yes
you have to modify this servername\shared$\test_ to fit your environment.

Webfred
Go to Top of Page

jamie_pattison
Yak Posting Veteran

65 Posts

Posted - 2008-08-08 : 09:28:39
Perfect - Thank you. It all works.

I dont suppose you know a site where i could learn more about expressions as i think it took hours just to get to the basics?

Thanks again
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-08-08 : 09:49:02
quote:
Originally posted by jamie_pattison

Perfect - Thank you. It all works.

I dont suppose you know a site where i could learn more about expressions as i think it took hours just to get to the basics?

Thanks again



I am sorry, but I don't know any site that can be recommended to this.
I am getting only snatches myself.
But try and error makes me a bit smart for that.

Maybe some of the experts on this sqlteam-site (i love this site) kann advice a good link.

Have a nice weekend!

Webfred
Go to Top of Page

rgombina
Constraint Violating Yak Guru

319 Posts

Posted - 2008-08-08 : 10:02:51
Here are some favorites...

1) Bunch of starter tips - http://www.sqlis.com/default.aspx
2) Video tutorials - http://blogs.msdn.com/mattm/archive/2007/06/12/ssis-tutorials-on-jumpstarttv.aspx
3) Google "ssis tutorials"

Of course... this site! Lots of helpful people here.
Go to Top of Page
   

- Advertisement -