Home Forums SQL Server 2005 Development Using Cursors Inside Stored procedure problem RE: Using Cursors Inside Stored procedure problem

  • You are right, even then it is not faster.

    Let me tell you the scenario,

    I have to generate a report which is having lakhs of records and need to dispaly it. i am fetching the records and doing adding it in my asp file itself.

    SQLStr1="Execute Report3_tbl_Trans_dummy "& txt_StateCode &","& txt_DistrictCode &",'"&txt_Date2 &"','"& txt_AccountNo &"','"& txt_DPCode &"'"

    response.write"sql --5" &SQLStr1 &"

    "

    'response.end

    adoRs1.ActiveConnection = DBCon

    adoRs1.Source = SQLStr1

    adoRs1.CursorLocation = 3'adUseClient

    adoRs1.CursorType = 0'adOpenForwardOnly

    adoRs1.Locktype = 1'adLockReadOnly

    adoRs1.Open

    response.write "recordCount for Step2_5-->"& adoRs1.RecordCount &"

    "

    Set adoRs1.ActiveConnection = Nothing

    FOR S=1 TO adoRs1.RecordCount

    IF UCASE(TRIM(adoRs1("int_TransCode")))="TR001" THEN

    TR1=CDBL(TR1)+CDBL("0"& adoRs1("flt_Amount"))

    ELSEIF UCASE(TRIM(adoRs1("int_TransCode")))="TR002" THEN

    TR2=CDBL(TR2)+CDBL("0"& adoRs1("flt_Amount"))

    ELSEIF UCASE(TRIM(adoRs1("int_TransCode")))="TR003" THEN

    TR3=CDBL(TR3)+CDBL("0"& adoRs1("flt_Amount"))

    ELSEIF UCASE(TRIM(adoRs1("int_TransCode")))="TR004" THEN

    TR4=CDBL(TR4)+CDBL("0"& adoRs1("flt_Amount"))

    ELSEIF UCASE(TRIM(adoRs1("int_TransCode")))="TR005" THEN

    TR5=CDBL(TR5)+CDBL("0"& adoRs1("flt_Amount"))

    ELSEIF UCASE(TRIM(adoRs1("int_TransCode")))="TR006" THEN

    TR6=CDBL(TR6)+CDBL("0"& adoRs1("flt_Amount"))

    ELSEIF UCASE(TRIM(adoRs1("int_TransCode")))="TR007" THEN

    TR7=CDBL(TR7)+CDBL("0"& adoRs1("flt_Amount"))

    ELSEIF UCASE(TRIM(adoRs1("int_TransCode")))="TR000" THEN

    TR8=CDBL(TR8)+CDBL("0"& adoRs1("flt_Amount"))

    END IF

    adoRs1.MoveNext

    NEXT

    adoRs1.close

    adoRs.MoveNext

    NEXT

    this is my code i am thinking that, since i am doing this calculation in asp file is that going to decrease my performance. is that, than how can i do this calculation in database itself.

    What are the steps i have to do, Either i have to write stored procedure or

    how can improve my sql performance by doing this