Thursday, May 28, 2015

Cursor Example in Sql Server 2008


 Declare @name nvarchar(max)  
 Declare cur cursor for  
      select username from userdet  
 open cur  
 fetch next from cur into @name  
 while @@FETCH_STATUS=0  
 begin  
      print @name  
      fetch next from cur into @name  
 end  
 CLOSE CUR;  
 DEALLOCATE CUR;  

No comments:

Post a Comment