Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
select colB, count(*)
from myTable
group by colB
having count(*) > 1
select * from myTable where colB = 0
--set up test data
declare @test table (colB int primary key clustered, val varchar(2))
insert into @test
select 5, 'PA'
union all select 3, 'MS'
union all select 19, 'KB'
--check pre-update
select * from @test
--establish variables used in update, initialize count
declare @cnt int, @minID int
set @cnt = 1
--loop through and update
while @cnt <= (select count(*) from @test)
begin
--get the lowest ID that is >= counter, in order to identify record to update
select @minID = min(colB) from @test where colB >= @cnt
--update the record
update @test
set colB = @cnt
where colB = @minID
--increment the counter
set @cnt = @cnt + 1
end
--check post-update
select * from @test
where code ='40' and filename PP.txt and Number >= @ResetNum327
update A_Table
set Number = @ResetNum327
where Number = @min327Num
and code ='40'
and filename = 'PP.txt'
Click on that link and follow the directions to award Alex a star.Thank AlexCuse
for this valuable post!