小编Dan*_*Spd的帖子

SQL Server重置所有表的标识增量

基本上我需要将所有表的Identity Increment重置为原始表.在这里我尝试了一些代码,但它失败了.

http://pastebin.com/KSyvtK5b

来自链接的实际代码:

USE World00_Character
GO

-- Create a cursor to loop through the System Ojects and get each table name
DECLARE TBL_CURSOR CURSOR
-- Declare the SQL Statement to cursor through
FOR ( SELECT Name FROM Sysobjects WHERE Type='U' )

-- Declare the @SQL Variable which will hold our dynamic sql
DECLARE @SQL NVARCHAR(MAX);
SET @SQL = '';
-- Declare the @TblName Variable which will hold the name of the current table
DECLARE @TblName NVARCHAR(MAX);

-- Open the …
Run Code Online (Sandbox Code Playgroud)

sql identity reset

24
推荐指数
5
解决办法
3万
查看次数

标签 统计

identity ×1

reset ×1

sql ×1