- Declare a CURSOR
- OPEN a CURSOR
- FETCH data in CURSOR
- finally close CURSOR
DECLARE @AccountID INT
DECLARE @getAccountID CURSOR
SET @getAccountID = CURSOR FOR
SELECT Account_IDFROM AccountsOPEN @getAccountIDFETCH NEXTFROM @getAccountID INTO @AccountIDWHILE @@FETCH_STATUS = 0BEGIN
PRINT @AccountIDFETCH NEXTFROM @getAccountID INTO @AccountIDEND
CLOSE @getAccountIDDEALLOCATE @getAccountID
DECLARE @getAccountID CURSOR
SET @getAccountID = CURSOR FOR
SELECT Account_IDFROM AccountsOPEN @getAccountIDFETCH NEXTFROM @getAccountID INTO @AccountIDWHILE @@FETCH_STATUS = 0BEGIN
PRINT @AccountIDFETCH NEXTFROM @getAccountID INTO @AccountIDEND
CLOSE @getAccountIDDEALLOCATE @getAccountID
No comments:
Post a Comment