clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36303 in the last week).

CREATE TABLE T1 (ID INT IDENTITY, FOO INT); CREATE TABLE T2 (NID INT IDENTITY, BAR INT); INSERT INTO T1 VALUES (1),(2),(3); INSERT INTO T2 VALUES (1),(2),(3),(4),(5);
8 rows affected
 hidden batch(es)


SELECT N'DBCC CHECKIDENT(''' + (C.TABLE_SCHEMA + N'.' + C.TABLE_NAME) + N''', RESEED, ' + CAST(COALESCE(IDENT_CURRENT(C.TABLE_SCHEMA + N'.' + C.TABLE_NAME) + 1, 0) AS NVARCHAR(30)) + ');' FROM INFORMATION_SCHEMA.COLUMNS C JOIN INFORMATION_SCHEMA.TABLES T ON C.TABLE_CATALOG = T.TABLE_CATALOG AND C.TABLE_SCHEMA = T.TABLE_SCHEMA AND C.TABLE_NAME = T.TABLE_NAME WHERE TABLE_TYPE = 'BASE TABLE' AND COLUMNPROPERTY(OBJECT_ID(C.TABLE_SCHEMA + '.' + C.TABLE_NAME), C.COLUMN_NAME, 'IsIdentity') = 1 --AND T.TABLE_CATALOG = 'YOUR_CATALOG' ORDER BY C.TABLE_NAME;
(No column name)
DBCC CHECKIDENT('dbo.T1', RESEED, 4);
DBCC CHECKIDENT('dbo.T2', RESEED, 6);
 hidden batch(es)