select *into #tempFrom tableXYZ
set identity_insert tableXYZ ON
truncate table tableXYZ
alter table #temp drop column (nameOfIdentityColumn)
set identity_insert tableXYZ OFF
insert into tableXYZselect * from #temp
declare @max intselect @max=max([Id]) from [TestTable]if @max IS NULL --check when max is returned as nullSET @max = 0DBCC CHECKIDENT ('[TestTable]', RESEED, @max)
USE mydb
-- ##################################################################################################################-- DANGEROUS!!!! USE WITH CARE-- ##################################################################################################################
DECLAREdb_cursor CURSOR FORSELECT TABLE_NAMEFROM INFORMATION_SCHEMA.TABLESWHERE TABLE_TYPE = 'BASE TABLE'AND TABLE_CATALOG = 'mydb'
DECLARE @tblname VARCHAR(50)SET @tblname = ''
OPEN db_cursorFETCH NEXT FROM db_cursor INTO @tblname
WHILE @@FETCH_STATUS = 0BEGINIF CHARINDEX('mycommonwordforalltablesIwanttodothisto', @tblname) > 0BEGINEXEC('DELETE FROM ' + @tblname)DBCC CHECKIDENT (@tblname, RESEED, 0)END
FETCH NEXT FROM db_cursor INTO @tblnameEND
CLOSE db_cursorDEALLOCATE db_cursorGO