I am trying to create a procedure to allow me to create one complete table using data from 2 seperate tables. I am able to do what I am trying to do but I feel I am being kind of repetative. I need to save this process as I will have to do this on new files periodically. I have been creating scripts using query analyzer to do this in real time, but have also save the procedures as stored procedures. The problem I have is that I wrote this procedure:
CREATE PROCEDURE sp_updateSutOB
AS
UPDATE tbl_distributorfinal
SET
tbl_distributorfinal.tt11status = 'Out of Business',
tbl_distributorfinal.tt11statusdate = suttm.reg_stat_date
from tbl_distributorfinal inner JOIN suttm
ON tbl_distributorfinal.taxreg = suttm.main_acct + suttm.sub_acct
where (((suttm.tax_type)='11') AND ((suttm.[reg_stat_code])='3'))
The Procedure works fine but i need to do it for 3 different suttm.tax_type 's (11,12 and 13) and 5 different suttm.[reg_stat_code].'s (1,2,3,4 and 5) This would require me to write 15 seperate procedures. Is there any way to batch this or include it in one procedure?
Thanks in advance,
Phil
CREATE PROCEDURE sp_updateSutOB
AS
UPDATE tbl_distributorfinal
SET
tbl_distributorfinal.tt11status = 'Out of Business',
tbl_distributorfinal.tt11statusdate = suttm.reg_stat_date
from tbl_distributorfinal inner JOIN suttm
ON tbl_distributorfinal.taxreg = suttm.main_acct + suttm.sub_acct
where (((suttm.tax_type)='11') AND ((suttm.[reg_stat_code])='3'))
The Procedure works fine but i need to do it for 3 different suttm.tax_type 's (11,12 and 13) and 5 different suttm.[reg_stat_code].'s (1,2,3,4 and 5) This would require me to write 15 seperate procedures. Is there any way to batch this or include it in one procedure?
Thanks in advance,
Phil