Site Search:
Sign in | Join | Help
4Penny.net

SQL Server (T-SQL)

Comments and notes on SQL Server 2000, 2005, and T-SQL

July 2008 - Posts

  • Cursor Template

    This is the cursor template that I use... it works better than the default one, and allows BREAK and CONTINUE easily

    DECLARE curName CURSOR LOCAL FAST_FORWARD FOR 
        select *
            from mytablename
    
    
    DECLARE variables
    OPEN curName
    WHILE 1=1 
    BEGIN
        FETCH NEXT FROM curName INTO 
        if @@fetch_status <> 0 begin
            break
        end 
    
    
    
    END
    CLOSE curName
    DEALLOCATE curName