dbTalk Databases Forums  

results of a sql command in a dts global variable

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


Discuss results of a sql command in a dts global variable in the microsoft.public.sqlserver.dts forum.



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

Default results of a sql command in a dts global variable - 05-18-2004 , 04:11 PM






I need to assign a couple global variables some information that would be
determined through a set of sql commands.

the 3 I have to have are a date & time, and a summed amount.

I have to grab info from 2 tables, grab everything from the first, and grab
only matching records from the 2nd, and then create a summed amount of the
money values on the 2nd table and stick that into a global variable to use
inside a DTS job.

Second one is date & time, but I need to remove the formatting . For
instance, 05/15/2004 would be 20040515 and 15:05:34 would be 150534.

The SQL to do these is here:

DECLARE @curDate As DateTime
DECLARE @curTime As DateTime

SET @curDate = GetDate()
SET @curTime = GetDate()

declare @charDate as char(8)
declare @charTime as char(8)

set @chardate = convert(char(8),@curDate,112)
set @charTime = STUFF(STUFF(convert(char(8),@curTime,114),3,1,''), 5,1,'')

I need to set what I have in @chardate & @chartime to 2 global variables
that'd be able to be referenced throughout the rest of the DTS job.

I can find some examples where you set global variables to be constants or
plain old assigning values to it, but not where they're set to the results
of a SQL command.

Any help/advice appreciated.


SC



Reply With Quote
  #2  
Old   
Ashish Ruparel [MSFT]
 
Posts: n/a

Default RE: results of a sql command in a dts global variable - 05-19-2004 , 07:38 PM






Hi,

You can save the row value to global variables by

1. Declare Global variables
2. In the "Execute SQL Task" click on the "Parameter" Button.
3. Switch to the "Output" tab
4. Select "Rowvalue" option
5. Map the output column names to one of the Global Vairables.
6. If you do not wish to have one of the columns mapped to the Global
Variables, let the mapping be None.

By doing this you will have the Last row's value saved in the respective
Global variables.

for further details visit
http://msdn.microsoft.com/library/de...us/howtosql/ht
_dts_task_722b.asp


HTH
Ashish
This posting is provided "AS IS" with no warranties, and confers no rights.


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.