Cursor in MS SQL

Using Cursor in MS SQL Server 2005 or 2008 Consider following code for creating cursor declare db_cursor CURSOR for SELECT ItemSLNO FROM P_Return_ItemSLNOTraking where Com_PReturnId_ItemId = @Com_ReceiveId_ItemId OPEN db_cursor FETCH NEXT FROM db_cursor INTO @ItemSLNO WHILE @@FETCH_STATUS = 0 BEGIN SET @SLNO = @SLNO+ ‘,’+ @ItemSLNO FETCH NEXT FROM db_cursor INTO @ItemSLNO END CLOSE db_cursor

Read More