Category: Queries

T-SQL query to get the latest available backup chain

T-SQL query to return the latest available database backup chain (Full, Differential and Log) of individual databases along with their backup size and compressed size.

T-SQL script to purge all the tables including foreign key references

T-SQL script to purge all the tables including foreign key references. The script has been made smart enough to use TRUNCATE wherever there is no foreign key reference and to use DELETE wherever there is foreign key reference.

Split data into N equal groups

In this blog post, you will get the query to "Split data into N equal groups" using SQL Server and you will also see the practical implementation of the following important topics of SQL Server. Happy learning ! 1) Ranking Functions (ROW_NUMBER() and NTILE()) 2) Local scoped temporary/hash table 3) CTE (Common Table Expression) 4) … Continue reading Split data into N equal groups