Reset to self-increment

2

I have a problem with my base fingers. I have the sending code as auto increment but whenever I delete a sending code the value does not reset or is not restarted is always increasing.

I wanted to know how to reset the number ... for example instead of starting at 36 start at 1

    
asked by anonymous 23.05.2015 / 16:22

1 answer

2

What you can do is to use the following command:

DBCC CHECKIDENT

This command checks the current identity value of the specified table and, if necessary, changes the identity value. You can also use DBCC CHECKIDENT to manually set a new identity value for the identity column.

BCC CHECKIDENT ( table_name [, { NORESEED | { RESEED [, new_reseed_value ] } } ] )

The parameters are:

table_name - This is the name of the table on which to check the current identity value. The specified table must contain an identity column. Table names must be compatible with rules for identifiers.

NORESEED - Specifies that the current identity value should not be changed.

RESEED - Specifies that the current identity value should be changed.

new_reseed_value - The new value to use as the current value of the identity column.

  

For your specific case I believe that the command:

DBCC CHECKIDENT ('dbo.envios', RESEED, 1)
     

Solve the problem.

More information here .

    
23.05.2015 / 16:58