Solved

doing a loop in a DTS Job in Sql server 2000

Posted on 2006-07-11
4
298 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

791 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