Re: Global Variable in Sub-Select Query -
02-08-2005
, 09:02 PM
Ok, left to my own will and determination, I came up with this, and it
works...
Step 1. I set prime to [zero] for all rows in my table.
Step 2. For each item that was only listed once, I set Prime to [one].
Step 3. I created a Global Veriable RecordSet that held the ItemID for
all the items that were listed more than once.
Step 4. I ran this ActiveX code...
'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************
Function Main()
dim uSQL
dim gv
'set the global variable
set gv = DTSGlobalVariables("gvMultiISBNOptyID").Value
'connect to the database
set myCon = CreateObject("ADODB.Connection")
myCon.Open = "DRIVER={SQL
Server};SERVER={server};UID={uid};PWD={pws};DATABA SE={database}"
'loop thru variable and execute my SQL
Do While NOT gv.EOF
'set my update string
uSQL = "UPDATE tblItem SET Prime = 1 WHERE RowID IN(SELECT TOP 1
RowID FROM tblItem WHERE ItemID = '" & gv.Fields(0).Value & "' ORDER BY
ItemOrder)"
set uRS = myCon.Execute(uSQL)
'clean up
set uRS = Nothing
'move next
gv.MoveNext
Loop
Main = DTSTaskExecResult_Success
End Function
'************************************************* ******
It worked!! I have to thank everyone in the group and the great info
on www.sqldts.com.
It might not be the prettiest, but it works and it's mine.
Steffany |