Solved

doing a loop in a DTS Job in Sql server 2000

Posted on 2006-07-11
4
285 Views
Last Modified: 2012-05-05
I need to run a loop around this block of code:
'**********************************************************************
'  Visual Basic Transformation Script
'************************************************************************

'  Copy each source column to the destination column
Function Main()
dim MainID      

      MainID = DTSLookups("GetRecordWithItem").Execute()
      DTSLookups("InsertLaptopItem").Execute(MainID)
      'DTSDestination("MainID") = DTSSource("ID")
      'Main = DTSTransformStat_OK
End Function

the DTSLookup GetRecordWithItem returns multiple records from a table
i need to run the insertLaptopItem for each of the mainId rows.

Please Help
Thanks
jcook32
0
Comment
Question by:jcook32
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:Einstine98
ID: 17084245
As far as I know the VBScript step will fire for each row...
0
 

Author Comment

by:jcook32
ID: 17084593
that is correct.
here are my look ups
SELECT     ID
FROM         HardwareInventory_ImportedData
WHERE     (LaptopModemCord = '1')

this will return many rows

INSERT INTO HardwareInventory_LaptopInfoRecords
                      (MainID, LaptopItemID)
VALUES     (?, 1)

i want to do an insert for each ID returned.

it is creating the records but the mainID field is the same for all records. 1
0
 
LVL 12

Accepted Solution

by:
Einstine98 earned 125 total points
ID: 17084642
why do you use a vb script for this? try using a SQL Query step with this

INSERT INTO HardwareInventory_LaptopInfoRecords
                      (MainID, LaptopItemID)
SELECT     ID, LaptoptModemCord
FROM         HardwareInventory_ImportedData
WHERE     (LaptopModemCord = '1')

this will insert everything for you.. and will be quicker
0
 

Author Comment

by:jcook32
ID: 17084818
that worked like a charm

thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now