Quick Reference Guide for SQL Server DBA Daily Tasks

Introduction As a SQL Server Database Administrator (DBA), daily operations can be time-consuming and require a vast amount of knowledge and experience. From managing backups to troubleshooting performance issues, a DBA's daily tasks can be daunting without a proper reference guide. That's where a cheat sheet or quick reference guide can come in handy. It... Continue Reading →

Azure Data Studio vs SSMS – Overview

Introduction When it comes to working with SQL Server, Microsoft offers two powerful tools: Azure Data Studio and SQL Server Management Studio (SSMS). While both tools are designed for managing SQL Server, they differ in several key areas. In this article, we will explore the features and benefits of each tool, and discuss which scenarios... Continue Reading →

T-SQL Query To Find Deadlocks In MS SQL Server

Introduction As a Backend Developer, I have frequently encountered performance issues, particularly those stemming from poorly written code or lack of indexes, which can lead to blocking conditions called "deadlocks." These situations can directly impact user experience and become more severe with frequent occurrences. This article addresses deadlock issues and reporting. Upon completion, readers will... Continue Reading →

Find Database Owner In SQL Server

Introduction In this simple article, let's explore different ways to find a Database owner. When a database is created, generally who creates it owns it and they have all permissions on that database. The Owner can perform maintenance of the database, grant permissions to other users, and even drop the database. Different Ways to Find... Continue Reading →

How to Identify Unused Tables In SQL Server

Introduction When working on large-scale projects, we might have created many tables, or later some point we might have changed the structure as part of the requirements. There is a huge possibility of tables that are not required or unused for a long time. A good practice is to remove/delete those by identifying them. In... Continue Reading →

Where are the SQL Jobs are Stored in SQL Server

Introduction In this article, We will discuss where the SQL Jobs are stored in SQL Server. Most of us know the purpose of SQL Job, A job is a specified series of actions that SQL Server Agent performs. Use jobs to define an administrative task that can be run one or more times and monitored... Continue Reading →

How to Check SQL Server Database Size

Introduction In this simple article, I would like to share how to check DB size. Sometimes when working in a Database, we may need to know the current space occupied by that particular DB. Based on the size, we need to take action. There are three easiest ways to check it, Using T-SQL StatementUsing SP... Continue Reading →

Find When was a SQL Server View Last Modified

Introduction In this simple tips and tricks article, I would like to share how to when was a view last modified. Let's have a look at the below T-SQL Statement SELECT name as ViewName, create_date as CreatedDt, modify_date as LastModifiedDt FROM sys.views In the above T-SQL Statement list, from the column LastModifiedDt column we can... Continue Reading →

Find Table Creation Date In SQL Server

Introduction In this article, we will discuss how to get the created date of a table. Sometimes, we may need to know when the table was created in the particular database. Rather than relying on the row inserted date, we can see when the table was created. Finding the Created date using T-SQL SELECT name... Continue Reading →

List All Available Time Zone – SQL Server

Introduction In this simple tips and tricks article, I would like to share how many time zones does our SQL Server supports. Well, it's pretty much easy to find by using the system table sys.time_zone_info sys.time_zone_info Here is the sample T-SQL to get the list of time zones our SQL Server supports. SELECT name AS... Continue Reading →

Execution Time of Stored Procedures In SQL Server

Introduction When working in SQL Server Stored Procedures, we are keen about the execution time of it. Its very simple to find execution time of stored procedures in SQL Server. Execution Time Its simple to figure out the execution time of stored procedures using SET STATISTICS TIME ON. SET STATISTICS TIME ON EXEC [Sales].[pGetSalesDetails] After... Continue Reading →

Different Ways To Get Table Column Names In SQL Server

Introduction In this simple article, we will discuss different ways to find the particular table's column names in SQL Server. Method One The first approach is using the system table sys.columns. This table results many columns, but we are interested only in the column name, so I am selecting name column from the sys.columns table,... Continue Reading →

Find Columns That Allows NULL In SQL Server

Introduction The columns in a table, that allows NULL in a database sometimes can lead to performance issues. The Nullable columns may be one of the reason to lead query to performance bad. By making columns NOT NULL can help the query to perform well. In this article we will discuss a simple way to... Continue Reading →

SQL Server Rank Functions

Introduction As like an Aggregate functions, the Ranking functions will rank the values of specified field and categorize them according to their rank . Ranking functions are most commonly used to find the top records based on conditions, example, to find the top ranking students, top highest paid employees and etc. Ranking Functions There are... Continue Reading →

T-SQL Query For Finding The Longest And Shortest names In A Table

Introduction In SQL Server, we can find the Longest String Value and Shortest String Value from the same table. To find the longest and shortest values, there are many ways, but in this article, we will discuss some simplest ways. Disclaimer: From this article, I am not sharing these are the only efficient ways to... Continue Reading →

MERGE Statement in SQL Server to Insert, Update, Delete Records

Introduction In a single transaction (MERGE Statement) we can perform Insert, Update and Delete records on a existing table based on the result comparison between important columns with another table. Which also means we no longer needs to write multiple T-SQL statements to handle Insert, Update, Delete. MERGE Statements To perform MERGE, we need two... Continue Reading →

Creating T-SQL Query Shortcuts in SQL Server Management Studio(SSMS)

Introduction Using keyboard shortcuts, it saves time, isn't it?. SQL Server Management Studio is also not an exception !!!. We can add our own custom keyboard shortcuts, that too for T-SQL query. Really cool !!!! How many of you know about this feature???. Do not worry if you did not know this before. Now you... Continue Reading →

Efficient Way Of Copying Database In SQL Server

Introduction Sometimes when working in Database, we may need to create another working copy of the current database or production database to check our new logic which should not affect the existing objects such as tables, stored procedures or etc. Example, suppose we may need to check few things using the Production database, but applying... Continue Reading →

SQL Query To Increase Salary By Percentage For All Employees In A Table

Introduction Sometimes we may need to increase the current column value by Percentage. The very good example is Salary in an organization. We need to update the salary of each employee based on the Hike Percentage. Increasing Salary By Percentage In this example, lets assume the Hike percentage is equal for all employees, and I... Continue Reading →

Retrieve Unsaved SQL Query Scripts

Introduction In this article, we will have a look how to retrieve the Unsaved SQL Query using T-SQL. Sometimes, we may close the Query Window or SSMS accidentally without saving. This may cause to loss the Queries which we where working. Retrieve Unsaved SQL Query using T-SQL Statement Apply the below T-SQL Statement in which... Continue Reading →

System Databases in SQL Server

Introduction In SSMS, we many of may noticed System Databases under the Database Folder. But how many of us knows its purpose?. In this article lets discuss about the System Databases in SQL Server. System Database Fig. 1 System Databases There are five system databases, these databases are created while installing SQL Server. MasterModelMSDBTempdbResource Master... Continue Reading →

Customize Azure Data Studio with Dashboard Widgets

Introduction Azure Data Studio is a free multi-platform database tool with built-in support for both SQL Server on-premises and Azure SQL Databases. These databases can be accessed in Azure Data Studio for numerous tasks like query editing, data development, built-in charting of T-SQL queries, etc. Database developers or Database Administrators often have a need to... Continue Reading →

Cycle Clipboard Ring In SSMS – Reuse Copied Items

Introduction As a developer, the most used shortcut keys are CTRL+C and CTRL+V i.e., copy and paste. But CTRL+C and CTRL+V allows us to copy paste the last item. But what happens if we want to paste more than one item that we copy or cut without going back? Cycle Clipboard Ring Cycle Clipboard Ring... Continue Reading →

Set custom colors to differentiate between environments in SSMS

Introduction Generally we have to shift between different environments within SQL Server Management Studio, as Dev Environment, Staging, Production, resulting in the creation of multiple query tabs. With each query tab connected to different environments. This leads to unmanageable sometimes and difficult to keep track of each environment. To resolve this confusion, SSMS provides us... Continue Reading →

Recover unsaved SQL queries in SSMS

Introduction During our productive hours, sometimes due to SSMS crashes or sudden machine reboots due to a windows update, during this time there is a possibility to lose the unsaved works / Script files. There is an option to recover our unsaved SQL queries in SSMS. How to recover unsaved SQL Queries By enabling the... Continue Reading →

Multiple Backup Files of the SQL Server database with SSMS and T-SQL

Introduction In this article, we will learn a simple tip to take multiple backup files of one Database. Sometime we may need more than one copy of a backup file in different file location and we can achieve that in two ways, either using T-SQL Query or using SSMS. T-SQL Statement BACKUP DATABASE [PracticalWorks] TO... Continue Reading →

Optimize your SQL Query – Replace Star (*) in Select Statement – MS SQL Server

Introduction Sometime we may need almost all the columns from a table result. In this scenario we use Star(*) in our select statement i.e. as SELECT * FROM TableName. Using Star(*) in the select statement is BAD. The best approach is selecting the table with column names. In this article we will learn how quickly... Continue Reading →

Website Built with WordPress.com.

Up ↑

%d bloggers like this: