Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reseed identity column in SQL Compact

Is it possible to reset the identity column in a compact database? I'm finding lots of answers regarding standard SQL Server, but no definitive answer regarding if it is possible using SQL CE.

Dropping and recreating the table is not ideal in my scenario!

like image 605
Mike Baxter Avatar asked Mar 07 '13 12:03

Mike Baxter


People also ask

How do I reseed an identity column in SQL?

Here, to reset the Identity column in SQL Server you can use DBCC CHECKIDENT method. Syntax : DBCC CHECKIDENT ('table_name', RESEED, new_value); Note : If we reset the existing records in the table and insert new records, then it will show an error.

Can you update an identity column in SQL?

You can not update identity column. SQL Server does not allow to update the identity column unlike what you can do with other columns with an update statement.

Can we drop identity column?

You cannot remove an IDENTITY specification once set. If you need to keep the data, but remove the IDENTITY column, you will need to: Create a new column. Transfer the data from the existing IDENTITY column to the new column.


1 Answers

ALTER TABLE [MyTable] ALTER COLUMN [Id] IDENTITY (1,1)
like image 60
ErikEJ Avatar answered Sep 30 '22 07:09

ErikEJ