Hi,
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'
BEGIN
SET @et_Processed = SUBSTRING(@Value1 ,3,11)
END;
ELSE
BEGIN
SET @et_Processed = SUBSTRING(@Value1 ,3,6) + RIGHT(@Value1 ,5);
END;
SET @NewCheckDigit = (CONVERT(BIGINT,@et_Processed) % 7) + 1
IF SUBSTRING(@Value1 , 3,1) = '9'
BEGIN
SET @Value1 = @Value1 + @NewCheckDigit
END;
ELSE
BEGIN
SET @Value1 = STUFF(@Value1 ,9,1,@NewCheckDigit)
END:
Any help would be appreciated
Thanks
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