Tuesday, 23 August 2011

Cursor


Cursor  following steps,

1.DECLARE CURSOR
2.OPEN CURSOR
3.FETCH CURSOR
4.PROCESSING
5.CLOSE
6.DEALLOCATE



-DECLARE CURSORDECLARE @NAME NVARCHAR(50)DECLARE
SET
SELECT
@SNAME CURSOR @SNAME = CURSOR FOR NAMEFROM ACCNAME--OPEN CURSOROPEN @SNAME --FETCH CURSORFETCH
FROM
NEXT @SNAME INTO @NAME--PROCESSING CURSORWHILE @@FETCH_STATUS = 0BEGIN
PRINT
@NAME--SELECT @NAME FETCH
FROM
NEXT @SNAME INTO @NAMEEND--CLOSE CURSORCLOSE @SNAME--DEALOCATE CURSORDEALLOCATE @SNAME
--SELECT FROM TABLENAME
SELECT
*fROM ACCNAME

No comments:

Post a Comment