Solved

doing a loop in a DTS Job in Sql server 2000

Posted on 2006-07-11
4
271 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
Comment Utility
As far as I know the VBScript step will fire for each row...
0
 

Author Comment

by:jcook32
Comment Utility
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
Comment Utility
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
Comment Utility
that worked like a charm

thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

772 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

10 Experts available now in Live!

Get 1:1 Help Now