Reset AutoIncrement when table is Empty?

rocopsarocopsa Member Posts: 38
Dear all,

I have developed a XMLport function and it is fine. Nevertheless, during my testing of importing, the PK ("Entry No.") was incremented into a large no.

Before deploying to customer, I want to reset the Entry No. to be start from 1. Although the table is empty, the Entry No. is not being reset.

I have a very stupid method, to rename the table ID, then, make it back again...... But this is not a good way to do so since it will mess up those dependent objects (codeunit, XML port,...)

Could anyone tell me how to do so? I have read many posts and cannot find the answer.....

Thanks a lot! [-o<

Answers

  • bbrownbbrown Member Posts: 3,268
    Is your database SQL or native? If it is SQL, see "DBCC CHECKIDENT" in SQL Books OnLine.
    There are no bugs - only undocumented features.
  • rocopsarocopsa Member Posts: 38
    Thanks bbrown! =D>

    Mine is SQL and your suggestion works well!

    To View:
    USE Database;
    GO
    DBCC CHECKIDENT (i]Tablename[/i, NORESEED);
    GO

    To Change the value:
    USE Database;
    GO
    DBCC CHECKIDENT (i]Tablename[/i, RESEED, 0);
    GO
Sign In or Register to comment.