重置自动递增 [英] Reset auto increment

查看:106
本文介绍了重置自动递增的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题从这里开始:如何为...设置自动增量基于服务的数据库

My question starts here: How to setup auto increment for Service-Based Database

因此,如果我必须通过这种方式在删除表行后重置自动增量:

So if I have to go this way to reset auto increment after deleting a table row:

http://befused.com/mysql/reset-auto-increment

我第一次处理T-SQL扩展和SQL.这里出了什么问题,不确定我是否正确:

first time I have deal with T-SQL extension and SQL generally. What is wrong here, not sure if I got it right:

CREATE TABLE [dbo].[Tab1] (
    [Id]     INT  IDENTITY (1, 1) NOT NULL,
    [Phrase] TEXT NOT NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC)
);

SELECT MAX( Id ) FROM [Tab1] ;
ALTER TABLE Tab1 AUTO_INCREMENT = number; 

遇到此错误:

严重性代码描述项目文件行抑制状态错误 SQL80001:"附近的语法不正确.预期为.",ID或QUOTED_ID. dbo.User 8

Severity Code Description Project File Line Suppression State Error SQL80001: Incorrect syntax near ''. Expecting '.', ID, or QUOTED_ID. dbo.User 8

和:

严重性代码描述项目文件行抑制状态错误 SQL80001:"附近的语法不正确. dbo.User 7

SeverityCode Description Project File Line Suppression State Error SQL80001: Incorrect syntax near ''. dbo.User 7

推荐答案

如果您想重新设定种子编号,可以在下面使用:

If you want to reseed to different number you can use below:

dbcc checkident(tab1, reseed, 100)

这篇关于重置自动递增的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆