Geeks With Blogs
Md. Saiful Islam February 2012 Entries
An alternative to cursor
While working with database we often require to use Cursor. Cursors force the database engine to repeatedly fetch rows. This may slow down your database and locking may occur. As a result cursor are not suggested to use if not extremely necessary. If there is a primary key on a table, you can usually write a WHILE loop to do the same work without incurring the overhead of a cursor. The following example demonstrate the idea: Declare @ItemId bigint Declare @OldItemCode varchar(50) SELECT Top 1 @ItemId= ......

Posted On Tuesday, February 7, 2012 11:28 AM

Copyright © saiful | Powered by: