Groups | Blog | Home
all groups > sql server dts > july 2004 >

sql server dts : Communicating between SQL & VBScript


Sayonara
7/14/2004 5:20:43 PM
Hey all,

Sorry to swamp the newsgroup buuut... In the ActiveX script area of an
Execute SQL Task is where my problem lies. I am having difficulty getting
SQL to talk to VBScript...

sqlstatement = "IF (SELECT COUNT(*) FROM "&
DTSGlobalVariables("Processed_Table").Value &" WHERE lastname LIKE '%,%') >
0"

I'm trying to get the line above (which simply checks if the lastname field
has a comma in it) to do the following: If TRUE (ergo, there are any commas)
then stop processing and send an email. If FALSE, then continue on following
the "success" arrows to completion.

Make sense? Of course I can execute the SQL statement through VBScript fine,
I just can't figure out my next step... Any help is greatly appreciated!
THANKS!!!

I will be a DTS pro yet!

Ilya Margolin
7/15/2004 9:47:34 AM
Sayonara,

If I understood correctly you would like to have two branches of execution
from the decision point and execute one of them depending on the result. In
this case I'd recommend those two branches be created as separate(detached)
with the first steps disabled. The decision step would set new two package
variables to -1 to leave the branch disabled or to 0 to enable it. You'd
need to add Dynamic Properties step to the decision step to set Disabled
property of first steps of the branches to the variables. The decision step
can be an Execute SQL Task (or ActiveX) with the following SQL and the
variables going as the output parameters:

SELECT DisableEmail = SIGN(COUNT(*)) - 1
,DisableProcessing = -SIGN(COUNT(*))
FROM Processed_Table
WHERE lastname LIKE '%,%'

Ilya

[quoted text, click to view]

Sayonara
7/15/2004 7:35:55 PM
Ilya,
What do "DisableEmail" and "DisableProcessing" reference below? I tried to
set them as global variables in an Execute DTS task, but am failing...

Thanks!

[quoted text, click to view]

Ilya Margolin
7/16/2004 8:58:06 AM
You have to add them first to Global Variables in the package Properties.

[quoted text, click to view]

AddThis Social Bookmark Button