0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SQL Server メモ書き

Posted at

SQL Server メモ書き 2020/11/18

1.Auto Increment(IDENTITY) が採用されているテーブルの次に割り振られるIDの確認をする。

SELECT IDENT_CURRENT('[TABLE]') AS ID

2.IDENTITYが採用されているテーブルのIDの現在地を現在のID値にリセット

--[SATORU] にはテーブル名を入力
DBCC CHECKIDENT ([TABLE], RESEED, 0); -- 実IDを 0 にリセット
DBCC CHECKIDENT ([TABLE]);            -- カウンタのIDを最大値にリセット
DBCC CHECKIDENT ([TABLE], NORESEED);  -- 実IDとカウンタIDチェック
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?