简体   繁体   English

如何使用Visual Studio 2008 Server Explorer将主键索引重置为1?

[英]How do I reset the Primary Key index to 1 using Visual Studio 2008 Server Explorer?

How do I reset the Primary Key index to 1 using Visual Studio 2008 Server Explorer? 如何使用Visual Studio 2008 Server Explorer将主键索引重置为1?

Thanks! 谢谢!

要将IDENTITY值重置为1,请使用DBCC CHECKIDENT

DBCC CHECKIDENT (‘YOUR_TABLE_NAME_HERE’, RESEED, 1)

It sounds like you have a table, with data, and you want to restart PK Identity numbering back to 1. 听起来你有一张表,有数据,你想重新启动PK身份编号为1。

You'll have to delete all data and reset the seed on the identity column. 您必须删除所有数据并重置标识列上的种子。 This can be done all in one statement. 这可以在一个声明中完成。

Create a new query by right-clicking on the database server or a table, and choose New query (or whatever command is similar): 通过右键单击数据库服务器或表来创建新查询,然后选择“新建查询”(或任何类似的命令):

TRUNCATE TABLE MyTable;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL服务器中如何使用主键删除数据? - How do I delete data using the primary key in SQL Server? 如何使用VS2008 Server Explorer在SQLite中创建表 - How do I create a table in SQLite using the VS2008 Server Explorer Visual Studio for SSRS 2008 - 如何在解决方案资源管理器中将报表组织到子文件夹中? - Visual Studio for SSRS 2008 - How to organize reports into subfolders in Solution Explorer? 如何管理Visual Studio 2008附带的SQL Server 2008? - how to manage sql server 2008 that came with Visual studio 2008? 如何在Microsoft SQL Server Management Studio数据库表中自动递增主键,数据类型声明为uniqueidentifier - How do I auto increment the primary key in a Microsoft SQL Server Management Studio database table, the datatype is declared as uniqueidentifier 如何在SQL Server 2008中创建复合主键 - How to create composite primary key in SQL Server 2008 如何在SQL Server 2008中创建组合的主键? - How to create combined primary key in SQL Server 2008? MySQL-如何使用列约束声明主键? - MySQL - How do I declare a primary key using a column constraint? SQL Server 2008:使用主键更新表 - SQL Server 2008 : update the table with primary key SQL Server 2008,规范化和主键 - SQL Server 2008, Normalization, and Primary Key
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM