Return to Snippet

Revision: 11794
at February 18, 2009 22:21 by rengber


Initial Code
declare @EntityName as varchar(100)

    declare DepNameCursor Cursor FAST_FORWARD 
    FOR select top 100 MailName from DepNameExt

    OPEN DepNameCursor
    FETCH NEXT FROM DepNameCursor
    INTO @EntityName

    WHILE @@Fetch_Status = 0 
    BEGIN 

        INSERT INTO [UDC].[dbo].[Entity]
           ([Name])
        VALUES
           (@EntityName)

        FETCH NEXT FROM DepNameCursor
        INTO @EntityName
    END

    CLOSE DepNameCursor
    DEALLOCATE DepNameCursor

Initial URL
http://msdn.microsoft.com/en-us/library/ms190028.aspx

Initial Description
Minimal syntax for cursor use.  See URL for SQL 2005 options and improvements.

Initial Title
Basic TSQL Cursor Syntax

Initial Tags
database

Initial Language
SQL