SSIS: dynamic source file connection - ssis

I am working in BIDS (SSIS 2008). I have a flat file connection to a pip-delimited file with a .pip extension. The file name can change significantly. However, it will always have the word 'stuff' in the file name. For example, a valid file name is 123_x_stuff_456.pip. How can I set up a dynamic connection for this dynamic file name?
So far, I have created a variable to hold the UNC path of the file (e.g., \drive1\folder1). My next step (I think) is to create an expression in the flat file connection manager to concatenate the file name to the UNC path variable. The problem I am running into is that I can't specify wildcards for the text before and after the token that I'm search for in the filename. For example, in SSMS, I would concatenate the UNC path variable to something like '%stuff%. For all tutorials that I've seen on this, they always follow a prescribed file name format, whereas, in my situation, the format will always be different (other than the token that it will always contain). How do I go about this?

Related

.csv file is not read by Jmeter

I have CSV DataSet Config where I have location of my .csv file
Tried both by writing the absolute path and putting my file in the same directory. Below is the screenshot
CSV file gets stored but the next line says it must exist
Below is mine HTTP Request
HTTP REquest
By running this in command Line nothing is getting stored in the my output file
I have tried that too.
Check following things:
Name of the file is correct. In case of Unix file names are case sensitive so check the name of the file and name you have mentioned in CSV data set configuration.
Keep the CSV file in the same folder where your JMX resides, and just mention file name in CSV dataset config. This avoids confusion in future even if you move the script to any other box.
Also make sure in the file there is no new line character at the end of the file. That will result in error.
Try a fully qualified path. ~/... was not working for me either - /temp/file.csv did the trick

File System Task failing to move ZIP files in SSIS 2005

Before we start: Yes, I have to use 2005. No, I can't upgrade, it's not my decision.
I have an SSIS package that is suppsed to perform the following tasks:
1. Zip a text file using 7-zip
2. FTP the file to a specified site
3. Move the zipped file to an archive folder
Steps 1 and 2 work fine, but when it comes time to move the folder it fails. The error message says, "Could not find a part of the path '\Shares2\clntrial\DataMgt\C1460\DataTransfer\Data\Sent\TXT\archive\ABC701_XXX_2015-09-30.zip\ABC701_XXX_2015-09-30.zip'." As you can see, it has the zip file name in the path twice.
That file destination path is set by a connection manager with the connection string populated by an expression that uses variables. When I edit the expression, it evaluates to the correct path with the file name appearing only once, that is, "\Shares2\clntrial\DataMgt\C1460\DataTransfer\Data\Sent\TXT\archive\ABC701_XXX_2015-09-30.zip".
Why is SSIS adding the file name a second time when the package runs?
Never mind, I'm an idiot. By including the zip file name "ABC701_XXX_2015-09-30.zip" in the destination I'm telling the file system task to consider that the target folder. Duh.

SSIS: How to change metadata on flat file connection manager

I am working in BIDS. I have an SSIS package that loops over all files in a given directory and imports all of them to a table. So, my control flow has a Foreach Loop Container with a Data Flow Task inside of it. The Data Flow Task goes straight from a Flat File Source to an OLE DB Destination. Because the directory can change, I have made the Foreach Directory dynamic (i.e., I gave it a package variable, which I can change when the directory changes). The Files field has something like stuff*.pip, such that all files in the directory that match this pattern get imported. The Variable Mappings tab has a file name variable, which is the same variable used in the Expressions of the flat file connection manager.
When I originally set up the flat file connection manager, I had to point it to an already existing file to pick up the file's metadata. I then changed the file connection manager to dynamic (i.e., I added a file name variable in the Expressions property) such that the Foreach Loop Container will pick up all files (that match the pattern).
Since then, the metadata on the file has changed. So, when I open the solution file, it throws a warning on the Flat File Source in the Data Flow Task. To resolve this, I have to temporarily change the flat file connection back to a hard-coded path such that I can change the metadata on the new file. I then make it dynamic again (i.e., use the file name variable in the Expressions, which overrides the hard-coded file path). (Finally, I double-click on the Flat File Source in the Data Flow Task to automatically update the metadata in the Flat File Source.)
Is this the correct way to update the metadata on a flat file? It seems a bit clunky to me.
You can prevent this error from occurring by editing the properties on the Flat File Manager and setting ValidateExternalMetaData=False.
You may also need to set DelayValidation=True on the Data Flow Task that contains the Flat File Manager.
This will prevent the warning - but if the file's metadata changes for some reason (columns change, data types change) and you do not remember to update the metadata then you will get a runtime error.

SSIS For Each Loop crashes the flat file connection

I created a simple SSIS package to import a flat file (.txt) into a database table. Tested that and it works perfectly. Since I have several files to import, I added a foreach loop to go through all the files, added the variables as recommended in several examples found on the net but now my flat file connection manager returns an error of "A valid file name must be selected." and the package will not run. I have so far been unsuccessful in finding the solution for this issue and would appreciate any suggestions by the SSIS gurus of this forum. Many thanks in advance!
Here is what I have in the way of variables:
SourceFileFolder which is the path to the folder that contains the files
FileName a string containing one of the names of the files I am seeking to import
SourceFilePath which is an expression driven variable that incorporates the previous two variables concatenated together. I can click "Evaluate Expression" and copy and paste it into windows explorer and open the file
ArchivePath which is an expression driven variable that creates the path to archive the file to once it is processed.
As the message says this is related to your connection manager not gathering the connection string. This can be handled using the following:
First of all clear the expression on the SourceFilePath variable.
With your Foreach Loop Container, set it up as follows:
This will use your variable SourceFileFolder as the Folder, you could also just hardcode the folder name C:\ for instance. Also make sure your folder is qualified correctly, I.E. make sure it finishes with a slash C: won't work but C:\ will work.
Next you need to map the fully qualified name to your other variable SourceFilePath
This should now store the full name of the file the loop has found into the SourceFilePath variable. For Instance C:\File.txt, you can now use this as a connection string expression on your file connection manager.
Under the properties of the connection manager make sure the expression is set to ConnectionString and then use the SourceFileName variable.
ALSO MAKE SURE DELAY VALIDATION IS SET TO TRUE
This hopefully should mean you can loop through the files.

Using SSIS Package Configuration to change flat file path?

I want to use the SSIS Package Configuration to change the path of several flat file destinations, but only the path, not the filename. Basically I have alot of flat files going to the same directory, but each has it's own name. Unfortunately the property on the flat file object includes both the filename and directory as one string. I would like to set it up so it is easy to change the directory for all of these, but where they still have their own unique filename.
Any ideas? Can this be done somehow with expressions?
Yes, can be done with Expressions.
Define a package variable for Path
Define an expression for ConnectionString with #[User:Path] + "\filename"
Use a package config to define the variable (or on command line)
I don't have SSIS on this PC so no screenies, sorry. Check this and this though