RSS

Monthly Archives: November 2015

sys.foreign_keys does not have matching row in sys.indexes

Running DBCC CHECKDB you are getting following error message:

Check Catalog Msg 3853, State 1: Attribute (referenced_object_id=194099732,key_index_id=7) of row (object_id=2040565179) in sys.foreign_keys does not have a matching row (object_id=194099732,index_id=7) in sys.indexes

This error means, that Unique key constraint (index_id 7) in the primary table (object_id 194099732) is missing, which was referenced by child table’s FK constraint (FK object_id 2040565179).  This should not happen, SQL Server will not allow you to drop a constraint that is referenced by FK.  If attempted should get following error message:

Msg 3723, Level 16, State 6, Line 1
An explicit DROP INDEX is not allowed on index ‘dbo.a.NonClusteredIndex-20151119-085219’. It is being used for FOREIGN KEY constraint enforcement.

So if we are suppose to get errors? Why do we have corruption; simple answer, someone be making updates to system tables directly, which is not allowed or supported!

Actually we are not able to update system tables in SQL Server 2005+ (ref), however in SQL 2000 days, we had setting called allow updates in sp_configure options.  Also supported by the KB2787112.

So question is how do you fix it?

First, identify the child table name from sys.foreign_keys:

SELECT object_name(parent_object_id) AS TableName
  FROM sys.foreign_keys
WHERE name = ‘FK_b_a’

Second, script our constraint definition:

  1. Find the table, we got in SQL Statement above.
  2. Go to Keys.
  3. Right click on FK constraint name.
  4. Script Key As.
  5. Create To.
  6. New Query Window.

Third, drop the FK constraint:

ALTER TABLE [schema].[tablename] DROP CONSTRAINT [fk_constraint_name]

Fourth, Re-create the constraint, with script generated in Step 2.

If it was issue of someone playing around in system tables, this should resolve it.  However, if you get error similar to below:

Msg 1776, Level 16, State 0, Line 1
There are no primary or candidate keys in the referenced table ‘dbo.a’ that match the referencing column list in the foreign key ‘FK_b_a’.

This means, that the key is missing in parent table and appropriate index needs be created before FK constraint can be created.  Since SQL doesn’t allow the index to be dropped there most likely are other corruption issues that have gone unnoticed.  If that is an issue, you will have to rely on your backups for recovery.

This post is cross posted on my SQLCAN Blog, MSDN Blog, and SQL server Consultation blog.

 
Leave a comment

Posted by on November 20, 2015 in Administration

 

Tags: , , , , ,

Cumulative update package 9 for SQL Server 2012 SP2 is available now

HI Followers Microsoft Announced about new cumulative update for SQL Server 2012 SP2 (Cumulative update package 9) and it come to fix around 13 Point in SQL Server (Master Data Services , Reporting Services , High Availability , SQL security , SQL service )

the most interested fixed for me is :

5285719 321185 This update introduces a new global property that exposes the latest CU number that is currently installed on the SQL Server. After you install this update, you can obtain the CU number information by executing either of the following queries:

SELECT @@VERSIONSELECT SERVERPROPERTY(‘PRODUCTUPDATELEVEL’)Additionally, this update also adds the CU number information to the first line of the SQL Server error log.

5646993 3097636 FIX: Performance decrease when an application that has connection pooling frequently connects or disconnects in SQL Server
5699533 3051145 FIX: SQL Server may shut down when you use Service Broker in SQL Server 2012 or SQL Server 2014
4272469 2682488 FIX: Backup operation fails in a SQL Server database after you enable change tracking

For more information about the Hotfixes go here

To know More about new feature in SQL Server 2016 you can check it from HERE

Follow Us :

LinkedIn Slideshare ,Youtube Channel.MSDN POSTS ,Facebook WHO WE ARE

 

 
Leave a comment

Posted by on November 19, 2015 in General topics, New Feature

 

Tags: , , , , , ,

Change DB Owner on all Databases one time

this one of wonderful scripts and very important 

—Change DB Owner on All Databases
EXEC sp_MSforeachdb ‘IF ”?” NOT IN (”Master”,”tempDB”,”model”,”msdb”)
BEGIN
EXEC [?]..sp_changedbowner ”User Name”
END

To know More about new feature in SQL Server 2016 you can check it from HERE

Follow Us :

LinkedIn Slideshare ,Youtube Channel.MSDN POSTS ,Facebook WHO WE ARE

 
Leave a comment

Posted by on November 16, 2015 in Administration

 

Tags: , ,

Live Query Statistics in SQL Server 2016

Today we have very good features it will help us in our daily work (Performance troubleshooting and for the debugging of queries) as we know to tune any SQL Server query you should Check first the Execution plan to decide from where the problem from SQL Server 2005 to SQL Server 2014 we have two types of Execution plan:

  • Estimated Execution Plan: Giving you an idea of how SQL Server will most likely perform query execution
  • Actual Execution Plan       : This will show you things that might hint at “out-of-date” statistics etc. But to get this, you must run the query – which can take a long time.

So before if we have case one Query returned Millions of record and we need to check the Query execution plan for it we will go directly for the Estimated Execution plan because actual Execution plan if we need to see it we will wait more time to the query finish and return all the result but Now in SQL Server 2016 we have new Execution plan type ” Live Query Statistics ”  this new features it will he;p us to see the Execution plan when the Query running and the Effect of the Query on the Execution plan step by step from more points:

  • Execution Query Percentage
  • Actual Number of Rows
  • elapsed time
  • operator progress

What I use here in my demo is simple Query return more than 8 Millions of records if I wait for this query to return all this data to see the Actual Execution plan I will wait around 20 Minutes but now in SQL Server 2016 I will See the Execution plan the Actual Execution Plan Live with Live Query Statistics 

SELECT *
FROM sys.all_columns tmp1
Cross JOIN sys.all_columns tmp2

Live Query3

Live Query1 Live Query2

To know More about new feature in SQL Server 2016 Keep following us and to check the previous posts in SQL Server 20116 you can check it from HERE

 
Leave a comment

Posted by on November 8, 2015 in SQL Server 2016

 

Tags: , , , , , , , ,

What is New in SQL Server 2016 Management Studio

Hello my followers today i will speak in very good Point in SQL Server 2016 all we are working on SSMS (SQL Server Mangment Studio) and we should now the options in this tools and what is the new on it so today we will show the new features in SQL Server 2016 Management Studio then later will explain deeply this features if it needed

  • In the installation you find new tape for Tempdb Configuration 
  • Check for Update : ( Now we can update the SQL Server Management Studio alone you will find it under tools )
  • 1- SSMS Update
  • Save Open Queries in SQL Server Management Studio (Tools > options > Query Execution > Prompt to save unsaved T-SQL Query Windows on Close)

Save unsaved T-SQL

Read the rest of this entry »

 
7 Comments

Posted by on November 5, 2015 in SQL Server 2016

 

Tags: , , , , , ,

SQL Server 2016 installation Error Rule “Oracle JRE 7 Update 51 (64-bit) or higher is required” failed.

Hello my Followers as we know Microsoft is going very fast for SQL Server 2016 RTM , Recently Microsoft announced about SQL Server 2016 CTP 3 “SQL Server 2016 Community Technology Preview 3.0” and this force us to learn more about the new features of this new SQL Server Release and to know ” What’s New in SQL Server 2016 “.

Problem

When i installed SQL Server 2016 CTP 2.4 i faced the below issue and this one we can solve it be the below solution

—————————
Rule Check Result
—————————
Rule “Oracle JRE 7 Update 51 (64-bit) or higher is required” failed.

This computer does not have the Oracle Java SE Runtime Environment Version 7 Update 51 (64-bit) or higher installed. The Oracle Java SE Runtime Environment is software provided by a third party. Microsoft grants you no rights for such third-party software. You are responsible for and must separately locate, read and accept applicable third-party license terms. To continue, download the Oracle SE Java Runtime Environment from http://go.microsoft.com/fwlink/?LinkId=526030.
—————————
OK
—————————

SQl Server 2016

Solution

  1. Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Click on Download on JRE as highlighted below

Untitled

Follow Us :

LinkedIn Slideshare ,Youtube Channel.MSDN POSTS ,Facebook WHO WE ARE

 
Leave a comment

Posted by on November 5, 2015 in SQL Server 2016

 

Tags: , ,

New TempDB Configuration in SQL Server 2016

SQL Server 2016 Logo

Hello my Followers as we know Microsoft is going very fast for SQL Server 2016 RTM , Recently Microsoft announced about SQL Server 2016 CTP 3 “SQL Server 2016 Community Technology Preview 3.0” and this force us to learn more about the new features of this new SQL Server Release and to know ” What’s New in SQL Server 2016 “.

In the Previous versions of SQL Server we couldn’t touch the tempdb Configuration while the SQL Server installation but now in SQL Server 2016 CTP 2.4 we can configure your Tempdb easily without any effort from the beginning

Tempdb Configuration in SQL Server 2016 2.4 :

  • By defalut now SQL Server 2016 Setup add 4 Data files for the Tempdb not like before one file only.
  • the default initial size is 8MB and the default autogrowth is 64MB.
  • we can now add specified data File in Specified Direction
  • During the Setup now we can configure the Data File , initial Size , Database Growth

SQl Server 2016 TemPDB

Follow Us :

LinkedIn Slideshare ,Youtube Channel.MSDN POSTS , WHO WE ARE

 
Leave a comment

Posted by on November 4, 2015 in SQL Server 2016

 

Tags: , , ,