Table column increment

  • I had created a table

    CREATE TABLE [dbo].[TransControl](

    [Trans_id] [int] IDENTITY(1,1) NOT NULL,

    [TransCode] [varchar](10) NOT NULL,

    [TransDescription] [varchar](50) NOT NULL,

    [DorC] [int] NOT NULL,

    CONSTRAINT [PK_TransControl] PRIMARY KEY CLUSTERED

    I had placed my Trans_id under column description as:

    Identity Specification :YES

    (Is identity) :YES

    Identity Increment :1

    Identity Seed :1

    Now i had deleted all the data from my table and i want to insert it again.

    When i insert the data again my Trans_id does not start from i instead it starts from 11.

    The reason y from 11 because my previous data were 10 records.

    My question is what can i do so that my Trans_id can start from 1.

    Please help me out.

    Actually iam doing a data migration????? and i want the id to start from 1 not 11.

  • DBCC CHECKIDENT

  •     Hi ,

         Reset Identity

       Try This

     

       dbcc checkident (TransControl, reseed, 0)

  • Hi,

    Thanks...

    It really made my life easier.............

  • Instead of deleting all the rows in the table try truncating it.

    TRUNCATE TABLE xxxxx

    The truncate command deletes all the data and resets the identity column.

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

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