If I'm reading the question right, you could use a combination of a few variables, a `cte`, and the `row_number()` function to write this type statement. You can add more conditions to the cte to get to the exact data set you are looking for, and drop the `TOP` variable if it isn't helpful. e.g. rextester: http://rextester.com/OIBEDZ93140 updated: http://rextester.com/TGZR4250 if exists (select * from tempdb.sys.objects where name like '#retailtransactiontable%') begin; drop table #retailtransactiontable; end; create table #retailtransactiontable ( [store] [nvarchar](10) not null , [terminal] [nvarchar](10) not null , [type] [int] not null , [transactionid] [nvarchar](44) not null); insert into #retailtransactiontable (store, terminal, [type], transactionid) values ('1','2',1,'Store1-Terminal2-T1'), ('1','2',2,'Store1-Terminal2-1'), ('1','2',2,'Store1-Terminal2-13'), ('1','2',2,'Store1-Terminal2-5'), ('1','2',2,'Store1-Terminal2-7'), ('1','2',2,'Store1-Terminal2-9') select * from #retailtransactiontable; declare @FirstTransactionIdToUpdate int = 5; declare @NewTransactionIdStart int = 2; with cte as ( select store , terminal , type , transactionid , transint = convert(int,(right(transactionid,charindex('-',reverse(transactionid))-1))) , newtransactionid = 'Store'+convert(nvarchar(10),Store) + '-Terminal'+convert(nvarchar(22),Terminal) +'-'+convert(nvarchar(3) ,((@NewTransactionIdStart+(row_number() over (order by transactionid))-1))) --, newid = (@NewTransactionIdStart+(row_number() over (order by transactionid))-1) from #retailtransactiontable where store='1' and terminal='2' and [type]=2 and convert(int,(right(transactionid,charindex('-',reverse(transactionid))-1))) >= @FirstTransactionIdToUpdate ) --select * from cte update cte set transactionid = newtransactionid; select * from #retailtransactiontable; before: store terminal type transactionid ---------- ---------- ----------- -------------------------------------------- 1 2 1 Store1-Terminal2-T1 1 2 2 Store1-Terminal2-1 1 2 2 Store1-Terminal2-13 1 2 2 Store1-Terminal2-5 1 2 2 Store1-Terminal2-7 1 2 2 Store1-Terminal2-9 after: store terminal type transactionid ---------- ---------- ----------- -------------------------------------------- 1 2 1 Store1-Terminal2-T1 1 2 2 Store1-Terminal2-1 1 2 2 Store1-Terminal2-2 1 2 2 Store1-Terminal2-3 1 2 2 Store1-Terminal2-4 1 2 2 Store1-Terminal2-5