dbTalk Databases Forums  

variable in transaction

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


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



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

Default variable in transaction - 03-01-2004 , 08:31 AM






I'm trying to figure out how to pass the same variable to the sql
statement and the transaction. I tried to specify a variable in my sql
syntax during the dts wizard but it didn't seem to like it. The value of
the variable will be used as a column in one place and a value for a
different column. What I'm looking for looks like this, where VARIABLE
is the same variable I want to pass:

select [results].[department], [results].[location],
[results].[VARIABLE]
from [results]

' Visual Basic Transformation Script
' Copy each source column to the
' destination column
'************************************************* **********************
*

Function Main()
DTSDestination("department") = DTSSource("department")
DTSDestination("location") = DTSSource("location")
DTSDestination("Answer") = DTSSource("VARIABLE")
DTSDestination("qid") = "VARIABLE"
Main = DTSTransformStat_OK
End Function

--------------------------------------
Michael Haas
WAN & Telecom Tech
Lenape Regional High School District

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: variable in transaction - 03-01-2004 , 11:37 AM






The problem will arise if you change the metadata for the transform. Make
sure you expose the [VARIABLE] as the same column Name/Alias.

select [results].[department], [results].[location],
[results].[VARIABLE] as MetaCol
from [results]


You can substitute the value of variable int your statement using this

Global Variables and SQL statements in DTS
(http://www.sqldts.com/default.aspx?205)

If you expose it as the same column Name each time then you will not need to
change it inside the transform as it will always be the same.


--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Mike Haas" <mhaas (AT) mail (DOT) lr.k12.nj.us> wrote

Quote:
I'm trying to figure out how to pass the same variable to the sql
statement and the transaction. I tried to specify a variable in my sql
syntax during the dts wizard but it didn't seem to like it. The value of
the variable will be used as a column in one place and a value for a
different column. What I'm looking for looks like this, where VARIABLE
is the same variable I want to pass:

select [results].[department], [results].[location],
[results].[VARIABLE]
from [results]

' Visual Basic Transformation Script
' Copy each source column to the
' destination column
'************************************************* **********************
*

Function Main()
DTSDestination("department") = DTSSource("department")
DTSDestination("location") = DTSSource("location")
DTSDestination("Answer") = DTSSource("VARIABLE")
DTSDestination("qid") = "VARIABLE"
Main = DTSTransformStat_OK
End Function

--------------------------------------
Michael Haas
WAN & Telecom Tech
Lenape Regional High School District

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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.