serial numbers in a query

  • i am using sql 2000. task is to develop reports with serial nos. report shd have the employee details in an organization. i have a function which accepts the employee code and gives all his details. in another function i have used a cursor to get list of employee codes of all employees. in this function i have used a variable for serial no in a while loop and inserting serial no and employee details and incrementing serial no.

    now prblem is first time if i run the query it works fine. but next t ime serial no is getting correct values.

    can anyone explain why this is happening

  • Heh... sure... you've done something wrong in the code. 😉

    There is no way possible to figure out what's wrong from here with what you posted. Discounting all of the RBAR you've built into the code, chances are, it's the way you're getting the next serial number.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • [font="Verdana"]you don't need another function to generate serial number. with some workaround you can generate serial number in the same query. if possible post your functions.

    Mahesh[/font]

    MH-09-AM-8694

  • Can you post the code for the function that gets the employee codes please, along with the code for any functions it calls. Also please post the table definition.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply