Category Archives: Script

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

SQL Recursive CTE example

* Recursive CTE

Posted in Script, SQL, SQL Query | 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

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

Search SQL Error Logs using TSQL – xp_readerrorlog

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

TSQL to find users and their access on a given database

TSQL to find users and their access on a given database

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

TSQL to find size of all databases on a Server – Azure

Posted in Azure, Script, SQL, SQL Query, SQL Server, Uncategorized | Tagged , , , , | 2 Comments