Code Library
This is my T-SQL (and not only) code library. I hope you will find some of the scripts interesting. You can expect this repository growing in the future.
![]() |
T-SQL script to list database files by location, size and free space Tested on: SQL Server 2005/2008/2008 R2 T-SQL script to list some database files information: type, name, location, size, free space. You can use it to check which files take the most of your storage or which files contain some free space. |
![]() |
T-SQL script to find query performance issues Tested on: SQL Server 2005/2008/2008 R2 T-SQL Script that I use the most often to find the queries with poor performance or high CPU usage. It returns some interesting data about each query: query text, name of the object the query belongs to, and some stats (reads, writes, CPU, duration). |
![]() |
Stored procedure for generating code that drops foreign keys referencing a table Tested on: SQL Server 2005/2008/2008 R2 Stored procedure sp_dropforeignkeys (marked as system procedure in master database – works in context of every database) that generates T-SQL code for dropping all foreign key constraints referencing a table (provide the name of this table as a parameter). |








