dbTalk Databases Forums  

global variable

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


Discuss global variable in the microsoft.public.sqlserver.dts forum.



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

Default global variable - 01-28-2004 , 06:56 PM






Any idea how can I create a global variable to change the
database name in the source and destination tab of the
tranformation (the database name part only - my_db.table1
to my_other_db.table1)?

I know I can create the global variable to change the name
of the database in the tranformation connection but that
does not change the database name in the source and
destination.

Thanks in advance for any help.


Reply With Quote
  #2  
Old   
RussLoski
 
Posts: n/a

Default RE: global variable - 01-28-2004 , 09:11 PM






Before diving into your issue, I have noticed that when Microsoft creates the target table in a transformation, it appends the database name. I would think that simply using TableName or dbo.TableName syntax would allow you to move the package from one database to another by simply changing the connection properties

You can change the source table name and the target table name in the disconnected edit menu option to change the source table name so that it has the syntax dbo.TableName, removing the database name entirely. You have to find the task (not the step) that corresponds to your transformation. Then you must find the SourceObjectName and the DestinationObjectName. You remove reference to the database and let DTS use the package connection information

Or you can use an activex script

'************************************************* ********************
' Visual Basic ActiveX Scrip
'************************************************* **********************

Function Main(

dim myTas
set myTask = DTSGlobalVariables.Parent.Tasks("Copy Data from DeclineList to [RussExperimental].[dbo].[DeclineList] Task"
dim sTabl
dim sD
dim iPo
sTable = myTask.CustomTask.DestinationObjectNam
sDB = DTSGlobalVariables("DestinationDB").Valu
iPos = instr(1,sTable,"."
if iPos > 0 the
myTask.CustomTask.DestinationObjectName = sDB & mid(sTable,iPos
end i

' Do the same with the SourceObjectNam

Main = DTSTaskExecResult_Succes
End Functio

Russel Loski, MCSD

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

Default RE: global variable - 01-29-2004 , 12:48 PM



Russel, Thank you so much. I changed the
DestinationObjectName and SourceObjectName for the tasks
in the disconnect edit menu choice and it works great.
It's a great help already but is there anyway I can have
that as default so I don't have to change for every
DTSTask_DTSDataPumpTask_1
DTSTask_DTSDataPumpTask_2
DTSTask_DTSDataPumpTask_3, etc

Now, I'm working in the ActiveX Script. Thanks again!

Quote:
-----Original Message-----
Before diving into your issue, I have noticed that when
Microsoft creates the target table in a transformation, it
appends the database name. I would think that simply
using TableName or dbo.TableName syntax would allow you to
move the package from one database to another by simply
changing the connection properties.
Quote:
You can change the source table name and the target table
name in the disconnected edit menu option to change the
source table name so that it has the syntax dbo.TableName,
removing the database name entirely. You have to find the
task (not the step) that corresponds to your
transformation. Then you must find the SourceObjectName
and the DestinationObjectName. You remove reference to
the database and let DTS use the package connection
information.
Quote:
Or you can use an activex script:


'************************************************* ********
*************
' Visual Basic ActiveX Script
'************************************************* ********
***************

Function Main()

dim myTask
set myTask = DTSGlobalVariables.Parent.Tasks("Copy Data
from DeclineList to [RussExperimental].[dbo].[DeclineList]
Task")
Quote:
dim sTable
dim sDB
dim iPos
sTable = myTask.CustomTask.DestinationObjectName
sDB = DTSGlobalVariables("DestinationDB").Value
iPos = instr(1,sTable,".")
if iPos > 0 then
myTask.CustomTask.DestinationObjectName = sDB & mid
(sTable,iPos)
end if

' Do the same with the SourceObjectName

Main = DTSTaskExecResult_Success
End Function


Russel Loski, MCSD
.


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

Default Re: global variable - 01-29-2004 , 02:56 PM



In message <E15550B3-B3A6-4AE7-82C4-E72C2932169F (AT) microsoft (DOT) com>,
RussLoski <anonymous (AT) discussions (DOT) microsoft.com> writes
<snip>
Quote:
I would think that simply using TableName or dbo.TableName syntax
would allow you to move the package from one database to another by
simply changing the connection properties.
Just to confirm, the method you describe works fine.

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



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.