SQL Data Counter

  • And, how does the app know what that latest value is?

    --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)

  • Jeff Moden (10/26/2008)


    And, how does the app know what that latest value is?

    Whenever any Insert Operation occurs on tbl employee counter_ins will be increment by 1.

  • rishgup (10/26/2008)


    Jeff Moden (10/26/2008)


    And, how does the app know what that latest value is?

    Whenever any Insert Operation occurs on tbl employee counter_ins will be increment by 1.

    Heh... yeah, I know that... I just don't see anything in your code that will return that number back to the app. I also don't see anything that will handle a multi-row insert.

    --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)

  • Jeff Moden (10/27/2008)


    rishgup (10/26/2008)


    Jeff Moden (10/26/2008)


    And, how does the app know what that latest value is?

    Whenever any Insert Operation occurs on tbl employee counter_ins will be increment by 1.

    Heh... yeah, I know that... I just don't see anything in your code that will return that number back to the app. I also don't see anything that will handle a multi-row insert.

    Jeff,

    I only have to count operation performed from Admin panel. And there is only one data entry operator, who logs in and perform operations. maximum operation is updation. i don't want anything on my app. I can run select query to see the data. My only worry is database performance. Will it effect performance???

  • You have to plan on the unexpected... what happens if, someday, there's more than one operator? And what happens if you have to do a "bulk" insert of more than one row for any reason? You've written a trigger that can only handle 1 row and all the others will have a problem if it ever happens.

    Also, yes... compared to using an IDENTITY column, the trigger will be a performance problem... but not for just one operator... I'd just plan on there being more than 1 and I'd plan on someone needing to insert more than 1 row someday.

    --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)

  • Jeff Moden (10/27/2008)


    You have to plan on the unexpected... what happens if, someday, there's more than one operator? And what happens if you have to do a "bulk" insert of more than one row for any reason? You've written a trigger that can only handle 1 row and all the others will have a problem if it ever happens.

    Also, yes... compared to using an IDENTITY column, the trigger will be a performance problem... but not for just one operator... I'd just plan on there being more than 1 and I'd plan on someone needing to insert more than 1 row someday.

    Can you suggest me something, what I should have to do? Any other way for counting operations?

  • Sure... read the very message of mine that you quoted... lookup IDENTITY in Books Online.

    --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)

  • Jeff Moden (10/27/2008)


    Sure... read the very message of mine that you quoted... lookup IDENTITY in Books Online.

    Jeff,

    By identity column you mean IS IDENTITY = 'TRUE' which will increment the identity column on insertion of record?

    What if we Delete any record or Update any record? It won't increment the Identity column. I just want numbers.

    Rishabh

  • rishgup (10/28/2008)


    Jeff Moden (10/27/2008)


    Sure... read the very message of mine that you quoted... lookup IDENTITY in Books Online.

    Jeff,

    By identity column you mean IS IDENTITY = 'TRUE' which will increment the identity column on insertion of record?

    What if we Delete any record or Update any record? It won't increment the Identity column. I just want numbers.

    Rishabh

    I'm not sure why you would update a column with the next number on just an Update... heh... never mind a Delete. Could you explain how the "numbers" you want are used just a bit more?

    --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)

  • Jeff Moden (10/28/2008)


    rishgup (10/28/2008)


    Jeff Moden (10/27/2008)


    Sure... read the very message of mine that you quoted... lookup IDENTITY in Books Online.

    Jeff,

    By identity column you mean IS IDENTITY = 'TRUE' which will increment the identity column on insertion of record?

    What if we Delete any record or Update any record? It won't increment the Identity column. I just want numbers.

    Rishabh

    I'm not sure why you would update a column with the next number on just an Update... heh... never mind a Delete. Could you explain how the "numbers" you want are used just a bit more?

    By number I means count. How many new records are added or deleted or how many records are updated. It my cleint requirement. He wants COUNT after every 15 days..

  • You don't need a counter for that... just store a date on every row and then count the rows in a data range.

    --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)

Viewing 11 posts - 16 through 25 (of 25 total)

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