Maybe not that you need, but this works
DECLARE
@id int,
@weight int,
@Field varchar(12),
@Result int
-- Test values
--SET @iD = 3
--SET @weight = 28
IF NOT EXISTS(SELECT id FROM [dbo].[weights] WHERE iD = @id)
BEGIN
INSERT INTO [dbo].[weights](id,shipweight1)
VALUES(@id,@weight)
END
ELSE BEGIN
SELECT @Result = shipweight2 FROM [dbo].[weights] WHERE iD = @iD
SELECT @Field =
CASE
WHEN @Result <> 0 THEN 'shipweight3'
ELSE 'shipweight2'
END
IF @Field = 'shipweight2' BEGIN
UPDATE [dbo].[weights]
SET shipweight2 = @weight
WHERE iD = @iD
END
ELSE BEGIN
-- check first if is null, for not overwrite
SELECT @Result = shipweight3 FROM [dbo].[weights] WHERE iD = @iD
IF @Result is null BEGIN
UPDATE [dbo].[weights]
SETshipweight3 = @weight
WHERE iD = @iD
END
END
END
-- SELECT * FROM [dbo].[weights] WHERE iD = @iD