Created
June 24, 2014 13:04
-
-
Save arijusg/e9d8d78ed4f2ecf4974e to your computer and use it in GitHub Desktop.
SQL Cursor usage
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
USE RedFoxAuto | |
DECLARE @PricelistID varchar(50), @lName varchar(50) | |
DECLARE cursorName CURSOR LOCAL SCROLL STATIC FOR | |
SELECT pricelistID, pricelistName FROM productPricelistNames | |
OPEN cursorName -- open the cursor | |
FETCH NEXT FROM cursorName INTO @PricelistID, @lName | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
PRINT @PricelistID + ' ' + @lName -- print the name | |
--SELECT @PricelistID, @lName | |
FETCH NEXT FROM cursorName INTO @PricelistID, @lName | |
END | |
CLOSE cursorName -- close the cursor | |
DEALLOCATE cursorName -- Deallocate the cursor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment