Stored Procedure to Delete Duplicate Records in SQL Table

Sometimes during our run as DBAs, we come up across at least one table that is loaded with duplicate records. Even if the table has a Primary Key (an auto-incremental one in most cases), the rest of the fields might have duplicate values.

However, SQL Server allows for many ways to get rid of those duplicate records (e.g. using CTEs, SQL Rank function, subqueries with Group By, etc.).

CodingSight - Delete Duplicate Records in SQL Table
Read More

The Stored Procedure to Get the Instance Settings

SQL Server instances house databases containing the data for the backend stack of a business model, or configuration data for particular applications. Regardless of the use case, an instance has a set of values/settings that should be tuned to follow best practices.

The purpose of the Stored Procedure that I’m showcasing in this article is to present the DBA a set of important settings/values that shouldn’t be overlooked. Moreover, I will share a cool feature that help DBAs keep control of any particular setting/value that has been recently changed/modified.

CodingSight - The Stored Procedure to Get the Instance Settings/Values
Read More

A Dedicated Stored Procedure to Get the Latest Database Backups Status

Any SQL Server DBA (of course, this applies to all platforms) will agree that database backups are the most essential things for data professionals. Monitoring those backups’ statuses is crucial. To make this task more straightforward, I have created a custom Stored Procedure. It will allow you to get the latest database backups’ (if any) statuses for all the necessary databases under your care.

CodingSight - a Dedicated Stored Procedure to Get the Latest Database Backups Status
Read More

3 Easy and Secure Ways to Make Users Run SSIS Packages

Have you ever come across a situation where you needed to make users run SSIS packages? This happens when the user is not comfortable with a fixed schedule for whatever reason. You can’t define if it’s every weekend, at 9 pm, or the 5th of the month. It happens when it happens.

This sounds problematic, depending on the volume of data. If you know that a million or so records won’t be advisable to process any time of the day, say no. But if the data volume is not a problem, what are your options?

Read More

SQL Server – Dissect the Internals of sp_spaceused

This article is an effort to dissect the output of the sp_spaceused stored procedure.


Understanding the database usage internals and the growth trends play a vital role in the defining the right sizing of the database. sp_spaceused is probably an administrator’s most widely-executed system stored procedure to find the disk space used by a database. This helps get a quick glimpse of the database usage. statistics. sp_spaceused is used to display the number of rows, the data size, index size, amount of used space, unused space by each object, and the unallocated size of the database. Although looking at the values given by sp_spaceused, one shouldn’t think of shrinking the database or data file or log file. Many a time, we are unaware of what we are doing. Many a time, we don’t know what would be the aftereffects of doing such resource intrinsic operations. The output of sp_spaceused tells us a lot about the current performance of the database. The unallocated column and the unused column tell us the free space left at the database and the table levels. Read More