dbTalk Databases Forums  

Passing a db name as a variable

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Passing a db name as a variable in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Peter
 
Posts: n/a

Default Passing a db name as a variable - 04-26-2004 , 06:56 AM






Is there a method for passing the database name as a variable to a DTS package
We have all item databases named as the business date i.e. 20040426AllItem and I'm manually having to re-select the database to run the DTS packages as I haven't found a way of passing the db name (I've also tried to incorporate the USE statement in the tranform data task query to derive the db name here but also without success).


Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Passing a db name as a variable - 04-26-2004 , 08:05 AM






You can use the Dynamic Properties Task to take a variable and set it to the
DB (Catalog) property of your connection. However by default the
SourceObjectname property of a DataPump task uses the three part name. You
can remove the DB part through Disconnected Edit to remove this "hard coded"
DB, or just use a (Source SQL Statement) SELECT statement that dos not
include the DB.

Conversely you can manipulate the SELECT SQL though an ActiveX Script Task
to include the DB variable such that it overrides the connection DB, using
the three part name in your SQL.


--
Darren Green
http://www.sqldts.com

"Peter" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Is there a method for passing the database name as a variable to a DTS
package?
We have all item databases named as the business date i.e. 20040426AllItem
and I'm manually having to re-select the database to run the DTS packages as
I haven't found a way of passing the db name (I've also tried to incorporate
the USE statement in the tranform data task query to derive the db name here
but also without success).
Quote:



Reply With Quote
  #3  
Old   
mndr
 
Posts: n/a

Default RE: Passing a db name as a variable - 04-26-2004 , 08:11 AM



You have to create a global variable in your DTS package and set its value to conection property 'Catalog' for example in ActiveScript task, something like that
oPkg.Connections("YourServerName").properties("Cat alog").value = DTSGlobalVariables("YourGlobalVariableName").Valu
or using Dynamic Property Tas

MNdreu

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.