How do you rebuild an identity column?
Answer / Indramani Sharma
"To rebuild an identity column in SQL Server, you can use the DBCC CHECKIDENT command followed by SET NOCOUNT ON and then SET IDENTITY_INSERT [table_name] ON. Here's an example:
```sql
SET NOCOUNT ON;
DBCC CHECKIDENT ('[table_name]', RESEED, 0);
SET IDENTITY_INSERT [table_name] ON;
UPDATE [table_name] SET [identity_column] = identity([identity_column]);
SET IDENTITY_INSERT [table_name] OFF;
```
This will reset the identity column to start from 1.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the system function to get the current user's user id?
what command is used to create a table by copying the structure of another table?
Can primary key be a foreign key?
Explain database normalization?
How do I setup a local sql server database?
What is difference in performance between insert top (n) into table and using top with insert?
How to get the query of a table in sql server?
what is a major difference between sql server 6.5 and 7.0 platform wise? : Sql server database administration
How do we return a record set from a Stored Procedure in SQl server 2000?
WHAT OPERATOR PERFORMS PATTERN MATCHING?
2 Answers CarrizalSoft Technologies, CTS,
What are the requirements for sql server 2016?
can you any body tell me why are go for the rebuild the master database.what is the reason?
Oracle (3253)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)