how to find initial value of identity column

  • Hi,

    How to find initial value of identity column programatically?

    I am using DELETE command to delete all the rows in a table and setting the table's identity column to initial value. Problem is, for some of the tables, initial value is not 1.

    Thanks,

    Ramu

  • use the ident_seed function for the table. for example, in the northwind database categories table:

    select ident_seed('categories')

    this will return 1

    hope this helps

  • If you truncate the table identity being reset to initial value automatically.

    _____________
    Code for TallyGenerator

  • Truncate isn't logged so, if you want logging (otherwise just truncate anyway - it's faster), delete first, then truncate.

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

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