jgoodman00
Programmer
- Jan 23, 2001
- 1,510
We have a number of fields which are currently graded as 'G', 'A', or 'P'. I am in the process of converting these to integer values based on a lookup table to this. In order to re-classify our existing data I wrote the following stored prcedure:
CREATE PROCEDURE dbo.Conditions AS
UPDATE InspectionImporter
SET AirpipeC = tblLUPCondition.ConditionID
FROM InspectionImporter INNER JOIN tblLUPCondition
ON InspectionImporter.AirpipeC = tblLUPCondition.Condition
GO
We have approximately 25 similar fields, so rather than creating & saving 25 seperate procedures, I thought I could create one, which contains all of the required update statements, & set it to run in batches as follows:
CREATE PROCEDURE dbo.Conditions AS
UPDATE InspectionImporter
SET AirpipeC = tblLUPCondition.ConditionID
FROM InspectionImporter INNER JOIN tblLUPCondition
ON InspectionImporter.AirpipeC = tblLUPCondition.Condition
GO
UPDATE InspectionImporter
SET AntiC = tblLUPCondition.ConditionID
FROM InspectionImporter INNER JOIN tblLUPCondition
ON InspectionImporter.AntiC = tblLUPCondition.Condition
GO
If I write this in the SQL query analyzer it executes perfectly. However, the stored procedure only saves the first statement, up to the first GO statement. Anything written after this appears to be deleted.
How else can I go about doing this, without saving each batch as a procedure? James Goodman
j.goodman00@btinternet.com
CREATE PROCEDURE dbo.Conditions AS
UPDATE InspectionImporter
SET AirpipeC = tblLUPCondition.ConditionID
FROM InspectionImporter INNER JOIN tblLUPCondition
ON InspectionImporter.AirpipeC = tblLUPCondition.Condition
GO
We have approximately 25 similar fields, so rather than creating & saving 25 seperate procedures, I thought I could create one, which contains all of the required update statements, & set it to run in batches as follows:
CREATE PROCEDURE dbo.Conditions AS
UPDATE InspectionImporter
SET AirpipeC = tblLUPCondition.ConditionID
FROM InspectionImporter INNER JOIN tblLUPCondition
ON InspectionImporter.AirpipeC = tblLUPCondition.Condition
GO
UPDATE InspectionImporter
SET AntiC = tblLUPCondition.ConditionID
FROM InspectionImporter INNER JOIN tblLUPCondition
ON InspectionImporter.AntiC = tblLUPCondition.Condition
GO
If I write this in the SQL query analyzer it executes perfectly. However, the stored procedure only saves the first statement, up to the first GO statement. Anything written after this appears to be deleted.
How else can I go about doing this, without saving each batch as a procedure? James Goodman
j.goodman00@btinternet.com