Category Archives: Script

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 , , , , | 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

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 , , , , | 1 Comment

Create SQL Script to restore Transaction logs

I was part of a Major incident this week and we had to restore days worth of transaction logs on multiple databases. Created SQL Query which generates the restore script

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

TSQL to find database count in each Elastic pool and its storage utilization – Azure

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