SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Dynamic Connections


Dynamic Connections

Author
Message
Mordred
Mordred
SSChasing Mays
SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)

Group: General Forum Members
Points: 636 Visits: 495
Hello All,

I have a package that downloads a lot of csv files and transfers their contents into a database. For one of the tasks in this package, I have a Precedence Constraint that evaluates the following expression:
@Table_Number == "3290056" || @Table_Number == "3290057" || @Table_Number == "3290058" || @Table_Number == "3290059" || @Table_Number == "3290060" || @Table_Number == "3290061" || @Table_Number == "3290062" || @Table_Number == "3290063" || @Table_Number == "3290064" || @Table_Number == "3290065" || @Table_Number == "3290066" || @Table_Number == "3290067" || @Table_Number == "3290068"

Basically what happens up to this is:

1. Download data based on a tblRelease_Dates query (if release is today, download).
2. Unzip the file (extract the csv)
3. Set the final destination path to archive the zipped files.
4. Start transform and load processes.

My problem is when the process flows get to the above precedence constraints. The previous line I gave checks which table is being transferred and loaded. However, I need to extract from the file in the folder with which-ever Table_Number is called. In the next step, I need to connect to the csv files and then load the values into a staging table. In the folder, the file name looks like: 3290056-eng.csv, 3290057-eng.csv, ..., & 3290068-eng.csv. If I do this the way I've learned, which is to create a connection using the connection manager, it will not be a dynamic connection so no matter which table number I'm on, it will only connect to the connection I make. How can I create a dynamic connection based on the table numbers. I'm going to play around in the Script Task sandbox to try and figure this out but I thought in the meantime I would ask first.

Regards:
Mordred
Keep on Coding in the Free World
herladygeekedness
herladygeekedness
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1314 Visits: 813
My understanding is that there is not the ability to have dynamic connections. I have split packages into mult pkgs to get around it.
Mordred
Mordred
SSChasing Mays
SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)

Group: General Forum Members
Points: 636 Visits: 495
Seriously? Darn! Now I'll have to make 11 different packages? Darn!

Regards:
Mordred
Keep on Coding in the Free World
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)

Group: General Forum Members
Points: 50475 Visits: 21152
Can you answer a couple more questions about your set-up:

1) Is the file format the same for all files?
2) Is this a common staging table, or is there one staging table per file to be imported?


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Mordred
Mordred
SSChasing Mays
SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)

Group: General Forum Members
Points: 636 Visits: 495
If by format you mean the type of file then yes, they are all CSVs. If you mean the format in the csv then no, they all differ a bit (column names may differ).

The staging table is a common staging table that is set up to accommodate all the csvs (at least so far it is).

Regards:
Mordred
Keep on Coding in the Free World
Mordred
Mordred
SSChasing Mays
SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)

Group: General Forum Members
Points: 636 Visits: 495
I've been working on a workaround for this. I've created individual connections for each CSV file. At a certain point in my package, and while using precedence constraints for each table, I have been able to connect to each file individually for my ETL processes. the attachment sort of shows.

Regards:
Mordred
Keep on Coding in the Free World
Attachments
My Process.JPG (13 views, 32.00 KB)
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)

Group: General Forum Members
Points: 50475 Visits: 21152
Mordred (5/15/2013)
I've been working on a workaround for this. I've created individual connections for each CSV file. At a certain point in my package, and while using precedence constraints for each table, I have been able to connect to each file individually for my ETL processes. the attachment sort of shows.


I think you're working along the right lines: check what sort of file it is and then execute the appropriate data flow - though I think I would have expected to see more things happening within the Foreach container.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Mordred
Mordred
SSChasing Mays
SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)

Group: General Forum Members
Points: 636 Visits: 495
I only showed a small part of the For loop container. Check the new image out to see that I'm doing a fair bit in there and I'm still adding.

Also, and this still has to do with connections, I got the following error when I started this up this morning:
Error 1 Error loading DownloadCSVPackage.dtsx: The connection "" is not found. This error is thrown by Connections collection when the specific connection element is not found. C:\Projects\EconAnalysisStatsCan\EconAnalysisStatsCan\DownloadCSVPackage.dtsx
I don't know how to find this blank connection, any ideas? I've scrolled my Connection Manager pane and don't see an connections named "".

EDIT: I've finished the workflow but I'm still seeing issues regarding the connection with a name "".

Regards:
Mordred
Keep on Coding in the Free World
Attachments
Workflow.JPG (5 views, 67.00 KB)
P Jones
P Jones
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2782 Visits: 1524
I've had that error when there's no value in the connection string
You'll need a default connection even if you are setting the actual connection with an expression that evaluates at runtime.

I have a similar sounding job which is a set of packages that import about four hundred csv files daily from four different business section zip file imports (from our outsourced business system) and the same file name and format is in each section i.e. file salsorders.csv will be the same format in each business section.
I use script tasks at the start to set up the correct import, error log and zip archive folders into variables and then a for each section number loop which does the import to combined staging tables which the next package converts and loads to live.
The connection string of a flat file is then an expression such as import folder variable plus file name plus section number variable plus extension.

I split the import section into sub-packages due to the slowness of working on each package and the whole thing is far more manageable. The dtutil batch script to deploy the packages is my most time saving utility!
Mordred
Mordred
SSChasing Mays
SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)

Group: General Forum Members
Points: 636 Visits: 495
You'll need a default connection even if you are setting the actual connection with an expression that evaluates at runtime.
Where do I set the default connection? I'm going to start looking now and will post an answer when I find it but if someone posts before I do I'm going to keep checking here.

Regards:
Mordred
Keep on Coding in the Free World
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search