Saturday, June 11, 2016

Looping through resultset without using cursor

Database:CasKoenigDB

Declare @dateval as datetime

Declare @Count int

Declare @Loopcount int

Select IDENTITY(int, 1,1) ID,items into #Temp from dbo.Split ( (Select cast (ExcludedDate as nvarchar(max)) from TRAN_EXCLUDEDAY where InterestedCourseId=1707),';')

Select @Count=@@ROWCOUNT

Set @Loopcount=1

While @Loopcount<=@Count

begin

Select @dateval=items from #Temp where ID=@Loopcount

Set @Loopcount=@Loopcount+1

print @dateval



end
 
Drop table #Temp

No comments:

Post a Comment