Sunday, July 22, 2012

Cursor using print values

Declare   MyCur Cursor for select Stud_Id,SName from Tbl_Student  where Stud_Id=1  
      Open MyCur 
         Declare @stud_id int
         Declare @sname varchar(50)  
    Fetch Next From MyCur Into @stud_id,@sname
    While @@Fetch_Status=0
    Begin
            PRINT @stud_id +' ' + @sname
           
             Fetch Next From MyCur Into @stud_id,@sname
    End          
      Close MyCur
      Deallocate MyCur