Sign in with Microsoft
Sign in or create an account.
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.


You run an SQL query that contains an IF EXISTS statement in Microsoft SQL Server 2012. If the IF EXISTS statement contains the dynamic management function sys.dm_db_index_physical_stats, you receive an access violation that resembles the following:

date time spid # * *******************************************************************************
datetime spid # *
datetime spid # * BEGIN STACK DUMP:
datetime spid # * date time spid #
datetime spid # *
datetime spid # *
datetime spid # * Exception Address = 000007FF7DA5614B Module(sqlmin+000000000000614B)
datetime spid # * Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION
datetime spid # * Access Violation occurred reading address 0000000800000F04
datetime spid # * Input Buffer 510 bytes -
datetime spid # * SQL_query_code
datetime spid # * end


  • If you run the DBCC CHECKDB command against that database after the access violation occurs, no error is reported.

  • The access violation does not occur when you first run the SQL query. However, the access violation does occur every time that you run the SQL query after that.

  • If you enable trace flag 3654, the access violation does not occur. However, you receive the following error in the trace instead:

    Location: sosmemdbg.cpp:2074
    Expression: FALSE
    SPID: 55
    Process ID: 16972
    Description: MEMOBJ_INDEXANALYSIS -- Unfreed memory detected.
    Msg 3624, Level 20, State 1, Line 5
    A system assertion check has failed. Check the SQL Server error log for details. Typically, an assertion failure is caused by a software bug or data corruption. To check for database corruption, consider running DBCC CHECKDB. If you agreed to send dumps to Microsoft during setup, a mini dump will be sent to Microsoft. An update might be available from Microsoft in the latest Service Pack or in a QFE from Technical Support.
    Msg 0, Level 20, State 0, Line 0
    A severe error occurred on the current command. The results, if any, should be discarded.


To resolve this problem, install Cumulative Update 7 for SQL Server 2012 SP1. This problem was first fixed in this cumulative update.

Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included in the previous cumulative update. For more information, check out the latest cumulative update for SQL Server 2012 SP1.


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.


See the terminology Microsoft uses to describe software updates.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?

Thank you for your feedback!