Quantcast
Channel: Everything SQL Server Compact
Viewing all articles
Browse latest Browse all 160

SQL Server Compact Code Snippet of the Week #13 : reseed (reset) an IDENTITY column

$
0
0

A question that keeps re-appearing in the forum is, how can I reseed/reset an IDENTITY column in SQL Server Compact, as no DBCC command is available. You can simply use a special syntax of the ALTER TABLE command to do this, as follows:

ALTER TABLE [MyTableName] ALTER COLUMN [Id] IDENTITY (1, 1)

This will make the value of the next generated IDENTITY value 1 and increment with 1. Notice that you do not specify the column type, only the IDENTITY specification.


Viewing all articles
Browse latest Browse all 160

Trending Articles