Category Archives: SQL

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 Advertisements

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

Add-on storage (Max storage choices) for Azure SQL Elastic Pools/ Databases – Great cost saving opportunity

If you have been using Azure SQL Elastic pools or databases (Platform As A Service – PASS), I strongly recommend to check your workload and validate Max storage choices! What change: Traditionally Each Azure Database and elastic pool had fixed … Continue reading

Posted in Azure, Productivity, SQL, Uncategorized, Useful Link | Tagged , , , , , , , , | Leave a comment

SQL Recursive CTE example

* Recursive CTE

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

What are default Index Maintenance settings in Ola hallengren maintenance solution

Summary: When Fragmentation < 5%, No maintenance When Fragmentation >= 5% and Fragmentation < 30 %; index ReOrganize When Fragmentation >= 30%; index Rebuild (If Supported online or Offline) Note: This is the default and regular scenario. check reference for … Continue reading

Posted in SQL, SQL Server, Uncategorized | 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

Address High CPU on SQL Server

Following are the guidelines to troubleshoot High CPU scenario in MSSQL Server and fix the problem. 1. Identify running SQL statements taking more CPU 2. Find sql_handle, using SQL handle find average execution time in ms, Number of executions, and … Continue reading

Posted in Execution Plan, Performance, SQL, SQL Server, Uncategorized | Tagged , , , | Leave a comment

Fastest way to fix MSSQL Database with Suspect mode

I had a situation where multiple databases (50+ Databases) changed to Suspect mode. Simple solution: (assume the DBs are in Server-A, Availability group and Server-B is configured as secondary server) * Fail over the availability group to Server-B * Resume … Continue reading

Posted in SQL, SQL Error, SQL Server, Uncategorized | Tagged , | Leave a comment