Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
|
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 2nd, 2005, 05:21 PM
Registered User
 
Join Date: Jan 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing a Global Variable Into a SQL Statement

I have a global variable in a DTS package that I need to concatenate with another value that is in a SQL select statement. Any idea how I can do this in a SQL task or Active X Script??

Ex:

Global Variable is gvPtJournalID

select id + dept + 0 + (add global variable) from tablename
where id = X

I need to pass in the GV into the statement then do the select

 
Old February 2nd, 2005, 05:40 PM
Registered User
 
Join Date: Jan 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes you can do it see example below

' 205 (Change SourceSQLStatement)
Option Explicit

Function Main()
    Dim oPkg, oDataPump, sSQLStatement

    ' Build new SQL Statement
    sSQLStatement = "SELECT * FROM dbo.employee WHERE hire_date > '" & _
        DTSGlobalVariables("HireDate").Value & "'"

    ' Get reference to the DataPump Task
    Set oPkg = DTSGlobalVariables.Parent
    Set oDataPump = oPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask

    ' Assign SQL Statement to Source of DataPump
    oDataPump.SourceSQLStatement = sSQLStatement

    ' Clean Up
    Set oDataPump = Nothing
    Set oPkg = Nothing

    Main = DTSTaskExecResult_Success
End Function








Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
Passing date variables into a sql statement hood8jmark Excel VBA 1 May 1st, 2008 01:05 PM
comapring global variable value to local variable amhicraig XSLT 6 December 5th, 2007 12:16 PM
Passing Variable MS Proj to SQL Stored Procedure Abaxt Access VBA 2 July 7th, 2005 11:05 AM
Passing global integers to SQL statements Kenny Alligood Access VBA 4 August 14th, 2003 10:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.