I am finding very strange behaviour inside while ...I have big stored procedure which do the calculation on business requirement . In my sp aim using while loop and its resulting duplicates.. I can't paste that proc here because it doing number of things that i will not be able to explain.. but i created same scenario to explain that issue.
declare @min int,@max int,@datarow varchar(2000),@id int
create table #table ( id int, datarow varchar(2000))
set @id= ''
insert into #table(id,datarow)
Select * from #table
Select @min=MIN(id) ,@max =MAX(id) from #table
--- Select @min, @max
Select @id=id,@datarow=datarow from #table where id =@min
Select @id as id ,@datarow as datarow
you can see that in my table #table has only two records with ids 1 and 4.
When I run above code which gives me result .
because of this 2 records converted on 4 records ...This loop shold only display two entries
Why this is showing extra records...Pleas suggest me on this tried every possible stuff but can't get rid of the this behaviour.
Vijay is here to learn something from you guys.