Thursday, September 19, 2013

Does a Cursor implement an execution plan ?

Hi Shiva,


For all the transactions execution plan will be created.


Attached the script for reference. Check in line comments for details.



DECLARE @CURTABLE TABLE (ID INT)
INSERT INTO @CURTABLE -- execution plan 1
VALUES(1),(2),(3)
SET STATISTICS XML ON
DECLARE @setid INT
DECLARE cur CURSOR FOR -- No execution plan, since declare
SELECT ID FROM @CURTABLE
OPEN Cur
FETCH NEXT FROM cur into @setid - execution plan 2
CLOSE Cur
DEALLOCATE cur



- Pls mark as answer/vote, if this post is helpful.


Sugumar Pannerselvam


No comments:

Post a Comment