you just write a stored procedure and check and update that in side that sp. You may use Business logic/service layer to do the same thing
create proc UpdateFilePosition
(
@FileName varchar(10)
,@ProposedPosition int
)
AS
begin
if exitsts(select * from MyPositionsTable WHERE FileName = @FileName AND Position = @ProposedPosition)
begin
UPDATE MyPositionsTable SET Position += 1 WHERE FileName = @FileName AND Position >= @ProposedPosition;
end
insert MyPositionsTable(FileName, Position) values (@FileName, @ProposedPosition);
end
Stored procedure check the provided file name and position is exists in table or not if found then it increase all positions by 1 started from proposed position. That way the proposed position will be unique.