the loop is not stopping

No need to use a loop, you can simply update with a query like:

declare @newrowid int = (select max(RowID) from Invoicing.dbo.Entries where ContractID = 21);

with q as
   select rowIDraw_data,  @newRowId + row_number() over (order by (select null)) - 1 rowIDraw_data_new
   from PSPS_transmission.dbo.historical_raw_data
update q
set rowIDraw_data = rowIDraw_data_new;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top