MuNiRs

Just another WordPress.com weblog

Sqlserver Cursors

Posted by Irfan Munir on March 4, 2008

DECLARE @ExpressionValue varchar(max)

DECLARE @GetExpressionValue CURSOR SET @GetExpressionValue = CURSOR  FOR SELECT  Expression FROM Expression 

OPEN @GetExpressionValue

FETCH NEXT FROM @GetExpressionValue INTO @ExpressionValueWHILE @@FETCH_STATUS = 0 BEGIN

            PRINT @ExpressionValue

FETCH NEXT  FROM @GetExpressionValue INTO @ExpressionValue

END

            CLOSE @GetExpressionValue

          DEALLOCATE @GetExpressionValue

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>