• john.arnott (10/21/2012)


    Good topic for a follow-up QOD (hope I don't steal any thunder here):

    If the code presented had one more statement amnd asked for the max(Ident)...

    CREATE TABLE IdentTest

    ( Ident INT NOT NULL IDENTITY (1,1)

    , varfield varchar(100)

    )

    INSERT INTO IdentTest VALUES ('xyz') -- <== Added to original

    DBCC CHECKIDENT ('IdentTest',RESEED,100)

    INSERT INTO IdentTest VALUES ('abc')

    SELECT max(Ident) FROM IdentTest

    What would be the output?

    Wouldn't it be the same (100)?

    If not, WHY NOT? (hard to make a QOD an essay question, but if you got this far, give it a shot).

    Very interesting. It kept me thinking....if there were more than 100 records in the table before Identity reseed command is executed...we have duplicate identity values 🙂

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter