Created
January 27, 2012 09:15
-
-
Save AndreasLazar/1687905 to your computer and use it in GitHub Desktop.
Using cursor with Common Table Expressions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- declare a cursor above the CTE definitions | |
DECLARE myCursor CURSOR FAST_FORWARD_FOR | |
-- declare CTEs | |
WITH CTE1 AS | |
( | |
-- CTE1 definitiion | |
) | |
,CTE2 AS | |
( | |
-- CTE2 definitiion | |
) | |
-- select query as normal | |
SELECT ... FROM CTE2 | |
-- now open and use the cursor and don't forget to close | |
-- and deallocate it in the end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment