Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to import the file that matches the file name patterns in SSIS?

Posted on 2011-10-15
6
Medium Priority
?
484 Views
Last Modified: 2013-11-10
I'd like to import the file from the Import folder. The system should only look for the files with certain patterns, such as CIS_ACCT_YYYYMMDD.csv, where YYYYMMDD are year, Month and Day.

How do I accomplish that?

BTW, I have already created the Foreach loop Task and File System Task. Do I need Script Task?
The path should be defined as avaraiable.
0
Comment
Question by:chuang4630
  • 4
  • 2
6 Comments
 
LVL 21

Expert Comment

by:Jason Yousef, MS
ID: 36974804
I do believe that you have a folder with multiple files and you need to grab only today's file?

Use an expression in the
 
"CIS_ACCT_" + (DT_WSTR, 4 )year(getdate())+ (DT_WSTR, 2)Month(getdate())+ (DT_WSTR, 2)Day(getdate())+".CSV"

Open in new window

0
 
LVL 1

Author Comment

by:chuang4630
ID: 36974968
There severl different type of data files:

NIMM_XT_YYYYMMDD.csv
CIS_ACCT_XX_YYYYMMDD.csv
CIS_MAINT_YYYYMMDD.csv

I have import all of them. Since they have different columns, it would be better if you create a task for each type.

So for this particular type, I only need to import CIS_ACCT_XX_YYYYMMDD.csv, where YYYYMMDD is the date and XX can be anything.
0
 
LVL 1

Author Comment

by:chuang4630
ID: 37136066
What if the file name is something like this:

XXX_YYYYMMDD, and/or
XXXX_YYYYMMDD

In other words, the identifier could be either three or four letters. How do i define the pattern in the expression?
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 1

Author Comment

by:chuang4630
ID: 37542079
Any comments?
0
 
LVL 21

Accepted Solution

by:
Jason Yousef, MS earned 2000 total points
ID: 37543418
HI,
Sorry I missed you replies.
It's easy, we'll evaluate from the right side then....or even reverse the string.

Right([YourColumn] , 13) == "_" + (DT_WSTR,4)YEAR(GETDATE())+Right( "0" + (DT_WSTR, 2 ) MONTH(Getdate()),2) +Right( "0" + (DT_WSTR, 2 ) DAY(Getdate()),2)  +".csv"

Open in new window



Here the condition will give you TRUE or False, you can use that in conditional split or precedence constraint .


Let me know if you need more help.
0
 
LVL 1

Author Comment

by:chuang4630
ID: 37903859
I'll try
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question