I would like to be able to update fields in a table and I believe that the following code will make the changes but I am not sure how to code the update to apply it to the table. Value1 forms part of a primary key
DECLARE @NewCheckDigit INT
DECLARE @Value1 VARCHAR(14)
IF SUBSTRING(@Value1 ,3,1) = '9'
SET @et_Processed = SUBSTRING(@Value1 ,3,11)
SET @et_Processed = SUBSTRING(@Value1 ,3,6) + RIGHT(@Value1 ,5);
SET @NewCheckDigit = (CONVERT(BIGINT,@et_Processed) % 7) + 1
IF SUBSTRING(@Value1 , 3,1) = '9'
SET @Value1 = @Value1 + @NewCheckDigit
SET @Value1 = STUFF(@Value1 ,9,1,@NewCheckDigit)
Any help would be appreciated
Without more information on table name and columns that you want to update and even with no criteria, I'll leave here an example of the update command:
Open in new window