Solved: Nonclustered Index Corruption in SQL Sever

Data Corruption is bad. Corruption either occur physically or logically in indexes. The Non-clustered Indexes are pointers of data that helps you in finding data more quickly. It contains Non-clustered key value and each key value has a pointer that contains the key value of data rows.Sadly, the ones who work in SQL Server is not aware about the processing behind it. The error of Non clustered Index is shown as:

<Date> <Time> spid # Error: 8646, Severity: 21, State: 1.
<Date> <Time> spid # Unable to find index entry in index ID 3, of table 2102402659, in database ‘'. The indicated index is corrupt or there is a problem with the current update plan. Run DBCC CHECKDB or DBCC CHECKTABLE. If the problem persists, contact product support.

Cause of Corruption in Non-Clustered Index

Index corruption occurs due to the NOLOCK hint run with any DML operation.This causes the query to read same value multiple times or read the table value incorrectly.

Sometimes it’s only the Non-clustered indexes that get corrupted, so you don’t have to run any restore operation on backups or run any repair command. Non- Clustered corruption is quite easy to handle, unlike, corruption in SQL data pages.You will able to fix it by running DROP and CREATE index.

How to Find Corrupted Indexes?

The consistency checks on indexes differ on the level of its compatibility of databases.

  • If the compatibility level <=100;
    • DBCC CHECKTABLE performs physical and logical consistency checks on all Non-clustered indexes and on the single table. By default, only physical consistency checks are done on XML Indexes, spatial indexes and indexed views.
    • In WITH EXTENDED_LOGICAL_CHECKS, logical consistency checks are performed on an indexed view, XML indexes, and spatial indexes. Only logical consistency checks are performed, if NOINDEX is specified.

Note: Running WITH EXTENDED_LOGICAL_CHECKS can highly affect the performance, therefore, you must use it only when:

  1. If you have issues related to Suspect index that are not related to physical corruption.
  2. Page level checksum is turned off.
  3. You suspect column- level hardware corruption.
  • If compatibility level >=90;
    • DBCC CHECKTABLE performs both physical and logical consistency check on a single table, indexed view and on all non clustered indexes. Spatial Indexes are not supported.

How to Fix it Manually

  • When nonclustered index is corrupted, the first step is to Run REPAIR_REBUILD command when the user is in SINGLE Mode.

  • Alter index IX_EmailAddress_EmailAddress
    on Person.EmailAddress

    The corruption FIXATION is not guarenteed because Rebuild reads the old index to build new one as a result of this new index contain the missing rows as old ones.

  • If Rebuild is not possible, then you need Drop & Create. Follow below procedure:
  • Right click on Indexes -> Select Script Index as DROP & CREATE to New query Window.

  • Run DBCC CHECKDB command to check consistency of the database.

Easy way to Repair Corruption By an Alternate solution

If you don’t want to perform lengthy process and want to save your time in repairing indexes, you can use professional third party SQL Recovery tool. The manual process is bit time consuming and may or maynot solve your problem. So you can use third party tool for an easy repairing. SQL Recovery software is capable of repairing corrupted indexes with an ease and fix your repaired indexes as a solution.


In this Blog, I have discussed about the solution to recover Non-clustered index in SQL Server Database. The blog covers two solution of repairing non clustered indexes. Choose the repair solution as per your ease.

Posted in T-SQL | Leave a comment

How to Repair Suspect Database in SQL Server with DBCC CHECKDB

Sometimes when connecting to the database, the database becomes inaccessible and you will get the following error message:

error message 945

The error message indicates that the database is in SUSPECT mode. Continue reading

Posted in T-SQL | Leave a comment

DBA Interview Question# Can we create a snapshot for MSDB system database?

DBA Interview Question# Can we create a snapshot for MSDB system database?

Recently I have been approached for one of my technical friend regarding the snapshot for system databases i.e. Master, Model. MSDB & TempDB whether possible or not.

As per Microsoft recommendation, snapshot is prohibited for Master, Model & TempDB so the question is here what about the MSDB snapshot, is it possible to generate?

Can we create a snapshot for MSDB system database?

Here I am sharing the details as an answer with you all after having  done a practical on it.


The answer is yes, we can create the snapshot for MSDB system database.


If we try to generate the snapshot for other system databases then we will get the error as below:

Model DB


Posted in Database Administration, Q & A, System databases | Tagged , , , , , , , | Leave a comment

Trace Flags in SQL Server

Trace Flags in SQL Server


Trace flags plays an important role in database administration. These are frequently used to diagnose performance issues or to debug stored procedures. For example trace flag 1222 is to detect the deadlock and returns the resources and types of locks pertaining in a deadlock

In SQL Server, there are three types of trace flags, query, session and global. Query trace flags are only active for the specific query. Session traces flags are active only for that particular session or connection. Global trace flags are set at the server level and are visible to every connection on the server.

There are several types of trace flags available. Here I’ll take mostly example of deadlock trace flags which is the most common for the DBA use.


Requires membership in the sysadmin fixed server role.



A global trace flag must be enabled globally, otherwise the trace flag has no effect. It is recommended to enable global trace flag at start up, by using the –T command line option. This ensures the trace flag remains active after a server restart.

The trace flag should be enabled with appropriate scope whether it is global, session or query scope. A trace flag which is enabled at the session level never affects another session, and the effect of the trace flag is lost when the SPID that opened the session logs out.

How to set Trace flags on or off



E.g. DBCC TRACEON (1222, -1)

The effect of enabling a global trace flag with DBCC TRACEON is lost on server restart.

To turn off a global trace flag, use

DBCC TRACEOFF with the -1 argument

DBCC TRACEOFF (1222, -1)


-T (T stands as Trace flag) start up option

The –T startup option enables a trace flag globally. We can’t enable a session-level trace flag by using a startup option. This ensures the trace flag remains active after a server restart. This can be done via SQL Server configuration manager.

Note: Here we can set the trace flag in Startup Parameters as “-T1222”.

How to start\stop traces:

Dbcc traceon (trace no) – for current session

Dbcc traceon (traceno, -1) – to enable globally

Dbcc traceon (no1, no2, -1) – enable multiple traces globally

How to check trace status:

Dbcc tracestatus

Dbcc tracestatus (-1) – display all globally enabled flags

Dbcc tracestatus () – display all trace flags enabled for current session


Note: Hi Friends,

Looking forward your thoughts on my blogs at least one liner email along with your name so that I can publish it with your name in coming blog. Kindly send it on my email id or using contact us here on the blog. Appreciate your time in advance.

Email Id:

Posted in Database Administration, Q & A, Sql Server | Tagged , , , , , , , , , , , | Leave a comment

SQL Server High Availability and Database Recovery Model Relationship

Recovery model

There are four types of high availability options available in Microsoft SQL server. All the options are different from each other. For example, Log shipping, Mirroring and Always On works on database level while Replication works on database objects level. The databases involved in these high availability feature must have a fixed type of recovery models else it is not possible to configure these options. Here I am briefing about the recovery models of the database which are involved in high availability.

HA &amp; Recovery Models

How to check the recovery model of a database?

Method 1:  sp_helpdb

Method 2: select name as [Database Name], recovery_model_desc as [Recovery Model] from sys.databases

How to change the recovery model of a database?

Method: T-SQL

Alter database database name set recovery full/bulk logged/simple


alter database Mirza set recovery full



Earn Money

Posted in Always on, Database Administration, Replication, Sql Server, T-SQL | Leave a comment

DBA Daily Tasks

sql-server DBA Daily Tasks

This blog is especially for those people who are preparing to be a Database Administrators or who have just started their career in the database administration field.

As a production DBA, we are supposed to perform several tasks on the servers on a daily basis to make and keep the server and database healthy. Monitoring the server is a key to safe our databases from any risk which may occurs in future. I am mentioning here only basic but very important tasks.

  1. Health Check of critical Servers
  2. Alerts from the servers needs to be acknowledged
  3. All the tickets to be checked and follow up
  4. Emails follow up
  5. Attend the scheduled client call
  6. Project work follow up
  7. Document the database environment

1.Health Check

Health checkup of the serves includes several checks which we need to perform on the critical servers and prepare a complete report. Here we need to check for database status, disk space utilization, CPU and Memory utilization, all the backups’ jobs and other maintenance jobs, error logs etc.

Important T-SQL commands can be used:

  1. Sp_helpdb
  2. Sp_spaceused
  3. Xp_fixeddrives

2. Alerts Acknowledgement

Any alert receives from the server via database mail or through any tool, we need to acknowledge and need to work upon them.

  1. Ticket Follow up

Mostly all companies use some ticketing system to get the database related issue \ task through it. All the tickets come with a SLA (service level agreement) which needs to be adhere and finish it within stipulated time frame.

  1. Email Follow up

Sometimes we get email from the client which contains a long list of database related talks which we need to work upon. So we have to follow-up on all emails and keep the status up to date without any fail.

  1. Call Attendance

For different project work related call with the clients, are scheduled and invitation goes to every team member. Therefore it is necessary for the DBA to attend the call and make the points clear on any ongoing work\ issue.

  1. Project Work Follow-up

Apart from daily routine work, project work also there which takes time and team do work side by side in parallel e.g. any database migration, AOAG setup on new servers, Server setup etc. Therefore we have to sync our self with the project work and keep updated on every task which is going on. By this way a new DBA can enhance his\her knowledge as well.

  1. Documentation

DBA performs several task in a single day and sometimes the task is a strange and new to DBA. We need to document all task either new or any project work to make every member of the team be on the same platform and make the life easy.

Earn Money !!! Click 

Make money from your Website or Blog with BidVertiser


Posted in Database Administration, Q & A, Sql Server | Tagged , , , , , , , , , | Leave a comment

Introduction to Microsoft Azure

Microsoft Azure

Microsoft Azure is an open, flexible, enterprise-grade cloud computing platform. Azure was announced in October 2008 and released on February 1, 2010.

It provides

Software as a service (SaaS)

Platform as a service (PaaS)

Infrastructure as a service (IaaS)

Why is it different from other cloud computing?

  1. Microsoft cloud is global, trusted and hybrid.
  2. 42 Azure regions, more than any other cloud provider
  3. 90% of fortune 500 companies use the Microsoft cloud.
  4. 1,20,000 new Azure customer subscriptions per month
  5. 62 compliance offerings more than any other cloud provider

Microsoft Azure – Popular Services\Products

  1. Virtual Machines
  2. App Services
  3. SQL Databases
  4. Storage
  5. Cloud Services
  6. Azure Cosmos DB
  7. Azure Active Directory
  8. Backup
  9. SQL Data Warehouse
  10. Traffic Manager
  11. Azure Database for MySQL
  12. Azure Databases for PostgreSQL


Posted in Azure, Database Administration, T-SQL | Tagged , , , , , , , , , , | Leave a comment