Select IDENTITY(int, 1, 1) as idno, * into #temp_price from XXXXXX declare @min int, @max int, @curr int, @isneedsent int declare @cSONO varchar(30), @sql nvarchar(4000), @ProdEngName varchar(50), @ProdChiName nvarchar(100), @PriMin numeric(14,4), @PriMax numeric(14,4), @PriCurr numeric(14,4), @SubSql nvarchar(1000), @ProdID char(10) select @min=min(idno),@max=max(idno),@PriMin=min(Min_value),@PriMax=max(Max_value) from #temp_price set @curr=isnull(@min,0) set @SubSql='' set @sql='' set @isneedsent=0 --,@PriMin=Min_value,@PriMax=Max_value while @curr<=isnull(@max,-1) begin select @cSONO=cSONo ,@ProdID=cProductID ,@ProdEngName=cProductEngName ,@ProdChiName=cProductChiName , @PriCurr=PriCurr from #temp_price where idno=@curr |