Category Archives: SQL Query

Find actively running SQL statements using Querystore-QueryID

TSQL to Find actively running SQL statements using QueryID

Posted in Performance, Querystore, Querystore, SQL, SQL Query, SQL Server | Tagged , | Leave a comment

QueryStore – Regressed queries based on execution count

Handy TSQL statement to find gergressed queries on a given time based on execution count. I had a scenario to validate if application is executing any statements more frequently on a given time. Following SQL can be used to find … Continue reading

Posted in knowledge, Performance, Script, SQL, SQL Query, Uncategorized | Tagged , , , , , | Leave a comment

What is azure sql database elastic pool split instance problem

Azure sql database elastic pool split instance problem is a very rare phenomena which could impact resource usage metrics of elastic pool. In this post I will cover how resource metrics are impacted, sample monitor, example of an impact. How … Continue reading

Posted in Azure, knowledge, Productivity, SQL, SQL Query, SQL Server, Uncategorized | Tagged , , , , , , | Leave a comment

T-SQL to find High availability configuration of all databases in MSSQL Server

 TSQL to find list of all databases in MSSQL Server with Always-ON and mirroring configuration. #mssql#tsql #AlwaysOn #Mirroring #FailoverMode #HighAvailability

Posted in Productivity, SQL, SQL Query, SQL Server, Uncategorized | Tagged , , , , | Leave a comment

SQL Recursive CTE example

* Recursive CTE

Posted in Script, SQL, SQL Query | Tagged , , , , , , | Leave a comment

Validate and delete duplicate records from MSSQL table

I had a situation where Index creation failed and business wants to delete duplicate entries immediately from a specific table. I had to validate the columns which are unique and which had different values. Following is easy script to validate … Continue reading

Posted in SQL, SQL Query, Uncategorized | Tagged , , , | Leave a comment

SQL Alwayson Preferred Node workaround, Fallback script

We have Always-On configured between Node-1, Node-2 with Auto Failover enabled. Unfortunately one minor functionality was partially impacted when AG is primary on Node-2. Business is very particular about not changing it to Manual Failover mode. End up creating a … Continue reading

Posted in Script, SQL, SQL Query, Uncategorized | Tagged , , , , | 1 Comment

Availability Group Fail Over date/time – TSQL

I have been using this quick script to verify AG Status Change details from error log.

Posted in High Availability, SQL, SQL Query, SQL Server, Uncategorized | Tagged , , , , , | Leave a comment

Interesting observation with DATETIMEOFFSET data type in SQL

Calculating daily max values of a table will be different if you are using/storing the data in DATETIMEOFFSET format. Basic difference is, while comparing the data between DATETIMEOFFSET and DATE (or DATETIME), DATETIMEOFFSET value will be converted to UTC and … Continue reading

Posted in Script, SQL, SQL Query, Uncategorized | Tagged , , , , | Leave a comment

Azure – All DBs that are not in Elastic pools

Posted in Azure, SQL, SQL Query, Uncategorized | Tagged , , , | Leave a comment