declare @name varchar(10)
declare @newpriority int
set @name = 'C'
set @newpriority = 1
declare @oldpriority int
select @oldpriority = priority from yourtable where name = @name
UPDATE yourtable
SET Priority = CASE
WHEN Name = @Name then @newpriority
WHEN @newpriority > @oldpriority THEN priority -1
WHEN @newpriority < @oldpriority THEN priority +1
ELSE Priority
END -- end of case
WHERE ( @newpriority > @oldpriority AND priority <= @newpriority AND priority >= @oldpriority )
OR ( @newpriority < @oldpriority AND priority >= @newpriority AND priority <= @oldpriority )
|