|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 2:42 PM
Points: 877,
Visits: 1,158
|
|
Hello,
We need to change the table name of 'OLE DB Destination' task. I am not able to use variable due to there are almost 20 data flow tasks in SSIS package and I need to use more variables.
Is it possible to update table name using SSIS Script task?
If yes, how can I use SSIS Script task to update the table name?
I am really thankful if you help me to resolve the issue.
Thanks
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: 2 days ago @ 5:12 AM
Points: 4,226,
Visits: 9,458
|
|
Do your various destination tables contain different column definitions, or do they all have exactly the same structure?
____________________________________________________________________________________________
Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 2:42 PM
Points: 877,
Visits: 1,158
|
|
Phil Parkin (1/14/2013) Do your various destination tables contain different column definitions, or do they all have exactly the same structure?
Table structure is same - columns, data types are same. For example: TableA & TableAa has same structures (columns, data types are same). TableA needs to replace with TableAa, same way TableB needs to replace with TableBb.
Thanks
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: 2 days ago @ 5:12 AM
Points: 4,226,
Visits: 9,458
|
|
There's nothing easy.
But if you don't mind writing some code, you may find that a Script Component Destination gives you the flexibility that you need. Have a look here.
____________________________________________________________________________________________
Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:13 AM
Points: 70,
Visits: 413
|
|
[[I am not able to use variable due to there are almost 20 data flow tasks in SSIS package and I need to use more variables.]]
Did you consider to use variable scoped to the task level? Thats what I do in ths same situation.
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: 2 days ago @ 5:12 AM
Points: 4,226,
Visits: 9,458
|
|
kenambrose (1/14/2013) [[I am not able to use variable due to there are almost 20 data flow tasks in SSIS package and I need to use more variables.]]
Did you consider to use variable scoped to the task level? Thats what I do in ths same situation.
How can you use a variable to switch a destination table name?
____________________________________________________________________________________________
Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:13 AM
Points: 70,
Visits: 413
|
|
If using Execute Sql task, make the sql text an expression and use variables for table names
If using oledb destination in data flow task, the data access mode property of the connection property allows you to use a variable tablename for the destination. see screen shot example.
There are a few tricks to doing this I found. The target table you point to in the IDE at design time must actually exist at design time. And of course each data flow can only support one data structure, although the target tablename can be dynamic at run time, the structure of the table cannot.
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:13 AM
Points: 70,
Visits: 413
|
|
I attached a screen shot of one way to have variables for object names for the OP, I am sure you already know how to do this for an ExecuteSql task.
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: 2 days ago @ 5:12 AM
Points: 4,226,
Visits: 9,458
|
|
kenambrose (1/14/2013) If using Execute Sql task, make the sql text an expression and use variables for table names
If using oledb destination in data flow task, the data access mode property of the connection property allows you to use a variable tablename for the destination. see screen shot example.
There are a few tricks to doing this I found. The target table you point to in the IDE at design time must actually exist at design time. And of course each data flow can only support one data structure, although the target tablename can be dynamic at run time, the structure of the table cannot.
Excellent - I'd forgotten about that option. Sounds like exactly what the poster needs.
____________________________________________________________________________________________
Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:13 AM
Points: 70,
Visits: 413
|
|
And actually, each target table must exist before the oledb destination with that table name fires up. However if needed, in the same "for each" loop a simple precedent step to the oledb destination step can check for existence of current tablename and create it if not found...
The real limitation is that oledb destination can't support dynamic data structure in addition to source and target tablenames- or at least I can't figure out how to do that...
|
|
|
|