Skip to main content

Simple Cursor Example in SQL

    DECLARE @Pram int

    DECLARE aCursor CURSOR
    FOR
        SELECT
            *
           
        FROM
            TableName
           
    OPEN aCursor
   
           
    FETCH NEXT FROM aCursor INTO
        @Pram
       
    WHILE @@FETCH_STATUS = 0
        BEGIN
            --'what you want to do hear'
            FETCH NEXT FROM aCursor INTO
                @Pram
        END
    CLOSE aCursor
    DEALLOCATE aCursor

Comments

Popular posts from this blog

crystal reports using stored procedures in asp.net

  crystal reports using stored procedures in asp.net   ReportDocument document = new ReportDocument ();         document.Load( this .Page.Server.MapPath( "~/CRY/crTest.rpt" ));         string str = ConfigurationManager .AppSettings[ "ConnectionString" ];         string server = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));         str = str.Substring(str.IndexOf( ";" ) + 1);         string database = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));         str = str.Substring(str.IndexOf( ";" ) + 1);         string user = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));        ...

Tata Punch: A Compact SUV That Packs a Punch