Skip to content

Instantly share code, notes, and snippets.

View Sebazzz's full-sized avatar
🏃‍♂️
Busy busy busy...

Sebastiaan Dammann Sebazzz

🏃‍♂️
Busy busy busy...
View GitHub Profile
@Sebazzz
Sebazzz / defragment-identity-fk.sql
Created January 21, 2017 11:26
Scripts to defragment (remove holes) between primary FK keys
-----------------------------------------
-- Script to "defragment" identity values in tables of the current database
--
-- Author: Sebastiaan Dammann
--
-- Global overview:
-- This script generates SQL statements you can use to remove gaps in identity
-- values in your SQL database. This script only operates on the dbo schema.
-- You can exclude tables for defragmenting via @tablesToSkip (LIKE query pattern).
--