I currently have a working sql 2000 program (SOEwkly.sql) which is made up of 3 steps. I basically need to run this program 30+ times. The only thing that changes each time is the table name it reads from and then save the tablename to a field in step1 (see green and red below). I am not sure if or how this can be done. Can someone help me with the coding? Thanks. -------------------------------------------- Step 1: Creates ByProduct table------------------------------------------IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'ByProduct') and OBJECTPROPERTY(id, N'IsUserTable') = 1) Begin create table ByProduct (Type char(20), Address char(50), SumOfNotional float, SumOfAvgBal float) CREATE INDEX CustID_IDX on CustBaseCase(AccountID) EndELSE Truncate TABLE ByProduct-------------------------------- Step2:------------------------------Create table ......---------------------------------------------------------- Step3: Performs match b/w 2 files & inserts sum of values to CustBaseCase table --------------------------------------------------------INSERT INTO ByProduct(Type, Address,city,SumOfNotional, SumOfAvg)SELECT 'CUSTBaseCase' as Type, Address, City,sum(s.notional) as SumOfNotional,sum(s.avgbal) as SumOfAvgfrom Parsed as w inner JOIN dbo.CustBaseCase as Son w.[w_id]=s.accountidgroup by type,city
