Quantcast
Channel: SQL Server Blog
Viewing all 1849 articles
Browse latest View live

SQL SERVER – SQL Browser not Starting. Error – The SQL Configuration for SQL is Inaccessible or Invalid

$
0
0

Today’s blog is originated from a blog interaction. After hardening a server, my friend was not able to start SQL Browser service. When we try to start from services, we get below standard error, which is not very helpful. Let us fix the error related to SQL Configuration.

The SQL Server Browser service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.

Then we looked into Event Logs and found below messages in application event log.

The SQL Server Browser is closing. There are no instances of SQL Server or SQL Server Analysis Services.

and below…

The SQL configuration for SQL is inaccessible or invalid.

Initially we thought that our SQL configuration is corrupted so we thought that we need to uninstall SQL Server. But NO, it was something else.

WORKAROUND/SOLUTION

We started SQLBrowser from command line and found error there also. Later, we found below registry key which is needed to start the SQL Browser.

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\90\SQL Browser

In our case, due to hardening, the key was deleted, so we created key and added two values under that.

SQL SERVER - SQL Browser not Starting. Error - The SQL Configuration for SQL is Inaccessible or Invalid browser-err-01-800x157

They keys are AnalysisServiceListener and SsrpListener and value should be 1.

Have you ever seen issues due to server level hardening by Windows team?

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – SQL Browser not Starting. Error – The SQL Configuration for SQL is Inaccessible or Invalid


#0401 – SQL Server – Script to validate object naming convention

$
0
0
When database development is done using the graphical (GUI) tools in the SQL Server Management Studio (SSMS) or via simple scripts, they often fail to specify a name to each individual constraint. This script can help the team validate object naming conventions.

Monday Coffee 2017-03-06

$
0
0

Last week Docker announced the availablity of Docker Enterprise Edition. The existing version of Docker that I’ve been using has now been renamed to the Docker Community Edition.

So what does this mean for us Windows people hacking around with Docker on our local Windows 10 boxes? Very little it seems. The Community Edition will have access to the full Docker platform and (if needed) can be added to with paid-for addons from the Docker cloud. I haven’t had a chance to look over all the paid offerings but they seem to be mainly cloud based services, so I doubt I’ll need them (at the moment).

The Enterprise Edition is interesting as it raises the question, is Docker suitable for SQL Server in production environments? Now, I’m a big fan of Docker and have been using it extensively in my dev/test environments but I’m still not sure about production.

If you think about the advantages running SQL Server in containers brings; simple to setup, quick to deploy; are they relevant to production? I want to spend time setting up my 24/7 critical SQL Server instance, speed of build doesn’t really matter.

There may be other advantages that Docker Enterprise Edition brings so I’m definitely going to check it out but there’ll have to be something pretty good in there to convince me SQL Server containers are for production.

Have a good week!


SQL SERVER – Installation Error – The Specified Driver is Invalid

$
0
0

SQL SERVER - Installation Error - The Specified Driver is Invalid installationsicon In this blog post we are going to learn about Installation Error – The Specified Driver is Invalid.

SYMPTOMS

SQL Server installation failed with errors in setup logs. Summary.txt shows below

Troubleshooting information for those features:
Next step for SQLEngine: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Next step for FullText: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Next step for Replication: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.

Above means that we need to:

  1. Find cause and resolved the error.
  2. Uninstall SQL Server.
  3. Run setup process again to install SQL Server.

Fine, now let’s look further down to know what was the cause of those three components install failure.

Feature: Database Engine Services
Status: Failed: see logs for details
Reason for failure: An error occurred during the setup process of the feature.
Next Step: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Component name: SQL Server Database Engine Services Instance Features
Component error code: 0x84BB0001
Error description: The specified driver is invalid.

This tells us that the error is “The specified driver is invalid.” I found below KB

https://support.microsoft.com/en-us/kb/933945 (Issues that you may encounter when you install a named instance of one or more SQL Server 2005 components and you specify different installation locations for one or more of the components)

But above is not applicable because we are install SQL 2012 not SQL 2005. As per books online documentation, I looked further into Detail.txt

lodctr: ‘E:\Program Files\Microsoft SQL Server\MSSQL11.SQLCAP\MSSQL\Binn\perf-MSSQL$SQLCAPsqlctr.ini’

(01) 2017-01-11 11:06:49 Slp: PerfCounter calling lodctr: ‘E:\Program Files\Microsoft SQL Server\MSSQL11.SQLCAP\MSSQL\Binn\perf-MSSQL$SQLCAPsqlctr.ini’

This failed with exact same error.When I opened below files, they were having some unreadable characters.

  • E:\Program Files\Microsoft SQL Server\MSSQL11.SQLCAP\MSSQL\Binn\sqlctr.ini’
  • E:\Program Files\Microsoft SQL Server\MSSQL11.SQLCAP\MSSQL\Binn\perf-MSSQL$SQLCAPsqlctr.ini’

When I checked from my laptop’s SQL instance, it was clearly readable. The path would vary based on instance name.

WORKAROUND/SOLUTION

We tried using the same media on another machine and it failed with the same error. I asked them to re-download the media as it looks like setup media is corrupted. After re-downloading media and we could install SQL Server on this machine.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – Installation Error – The Specified Driver is Invalid

SQL SERVER – Queries are in KILLED/ROLLBACK State with Wait PREEMPTIVE_OLEDB_RELEASE

$
0
0

There are many wait types in SQL Server and not all of them are documented. Long ago I wrote blog on PREEMPTIVE and Non-PREEMPTIVE waits. SQL SERVER – PREEMPTIVE and Non-PREEMPTIVE – Wait Type – Day 19 of 28. In this blog post we will take a look at how to solve wait PREEMPTIVE_OLEDB_RELEASE.

Once I was contacted when there was wait of PREEMPTIVE_OLEDB_RELEASE seen in SQL Server. Here are the few columns from sys.dm_exec_requests.

SQL SERVER -  Queries are in KILLED/ROLLBACK State with Wait PREEMPTIVE_OLEDB_RELEASE PREEMPTIVE_OLEDB_RELEASE-800x188

There was no documentation available for this wait type. From the name, it looks like some kind of cleanup (release) task.  Here was the behavior which I saw.

  1. All above were in RUNNING state.
  2. ONLY wait duration and elapsed time column values were increasing.
  3. There was a network outage earlier, which caused few SPID to run continuously so they were killed and now sitting in KILLED/ROLLBACK state. They were running UPDATE statements earlier.

WORKAROUND/ SOLUTION

As on the internet, there was no other help on this subject and there is no further documentation available from Microsoft as well. The customer was really keen on removing this wait stats. The good thing for us that their maintenance window was coming up on the very same day.

I explained to my client that they should restart the SQL instance to remove those sessions. And as expected, restarted to clear those SPIDs.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – Queries are in KILLED/ROLLBACK State with Wait PREEMPTIVE_OLEDB_RELEASE

Confused with Big Data, Data Science and Data Analytics

$
0
0
Often people confused with Big Data, Data Science and Data Analytics. Are they same or different.
This link will give you an idea about what are they, what skills you need and what are the salary levels.

Read more to get further details https://intellipaat.com/blog/compare-big-data-data-science-data-analytics/

KPIs For DBAs to Show Their CIOs

$
0
0

It is perfectly valid for a DBA (or their manager) to assign KPIs to the servers and databases they administer. KPIs are unique for every shop, and for every role.

The post KPIs For DBAs to Show Their CIOs appeared first on Thomas LaRock.

If you liked this post then consider subscribing to the IS [NOT] NULL newsletter: http://thomaslarock.com/is-not-null-newsletter/

Keeping the golf score card after 20 years in IT; reflections on International Womens’ Day

$
0
0

On International Womens’ Day, I think about my journey how I got here today. Other women may have similar experiences. Unlike Jenni Murray, I believe that you can be trans, proud and a real woman. Just saying.

Over the years, I have had challenges as a female IT consultant. Here are a few choice examples taken from my 20 years working in IT:

– a business contact once rubbed his hand up my leg when he thought I was asleep on a plane next to him. I jumped out of my skin. I realise now that he was trying to figure out if I wore tights or suspenders, and he was looking for the ‘line’. The skinny; I wear black 40 denier tights because I have varicose veins on my legs like a roadmap. They are comfortable and I like them. Oh, and don’t wake me up when I’m sleeping… although I know that he didn’t mean to…..
– Whilst at a conference, some business contacts trying to keep a golf score card and challenging other colleagues to try to get me into bed, using the golf score card to keep track of points when someone spoke to me or double points if I accepted a drink (for example).  I found the golf score card with the names and scores on it when one of them dropped it on the floor. I was extremely humiliated, and realised why folks had been so friendly and welcoming to me. They grabbed the card back, but I wish I still had it – to remind me.
– I’ve had my work actively sabotaged by someone who told my boss that he could not fathom the idea of senior female tech lead and genuinely believed I got the role for being female and to tick boxes;
– I’ve been told to my face that I am ‘not close enough to the kitchen sink’. Unfortunately for them, I was made their technical lead one month later on merit, and they had to put my presence in their pipe and smoke it. I was gracious about it since  I needed them to deliver well for me since the results would prove my worth. They delivered well, and I delivered the whole project on time, on budget,and to spec.
– I’ve had my email mailbox deleted on one site because I was the only female out of 200 plus men, and I ‘destroyed the all male equilibrium’ of the IT department. That was escalated to C-level, and nobody spoke to me after that because I’d complained. You can’t win, can you? I needed to deliver the project, and needed email. I did deliver, on time, on budget, to spec with a kindly Project Manager forwarding me emails to another account so I had everything I needed, and ensured I wasn’t cut off email trails.
– I am usually the victim of someone discrediting me as being too ’emotional’ and/or ‘not technical’.
– I’ve had men refuse to share an office with me in case I am ‘unclean’
– Discussions of female sanitary items; do I prefer ‘wings’ or not?

It’s the small things; for example, not responding to your email on a thread, but to the second-last email on a thread so that your contribution is cut out. Yes, I see you… but so does everyone else. Not clever and easily provable.
Sometimes it is not overt; it can simply be that I’m mansplained, or interrupted constantly.  It’s a case of people simply never having the capability of believing that women can do anything technical and they will glibly reconcile it as other ways e.g. I am a ‘statistical oddity’. I like that, actually.

This doesn’t include the hugs where the hands just goes a little too low, or the colleague who leans towards me a little too close, or who looks at a part of you for a little too long. You don’t have to be attractive or pretty to experience that.

Here are some takeaway actions for you:

Shout louder to get your voice heard. Your voice is a good one. If people are tone deaf at the start, you haven’t lost anything anyway!
Throw your light out farther, and help others do the same. All of the setbacks have made me simply want to throw my light out farther. So, this blog post here was the result of a meeting that day, where I was being discredited subtly 
Be helpful; you’ll be nicer to work beside, you’ll get more projects and more ‘wins’ in the long term. In the situations above, there was usually someone good enough to help. Be that person.

Be communicative; be the person who forwards email trails to anyone who has been actively cut out of it (male or female!)

Be considerate: the person who considers promoting the quiet female on the team. She’s probably good, you know.

Anywhere can be Trump’s Locker Room. Trump’s talk of ***-grabbing and locker room? He was wrong to say that, and wrong to say it was ‘locker room’. It can be anywhere. Offices, work parties, conferences, anywhere.Be the person who steps in and takes away the ‘golf score card’ when it’s being used to keep a track to see who can get her into bed. Tell them to ‘grow up’. That’s not just locker room talk; that’s everywhere. Be the person who helps to stop it before it starts.

If someone is being victim-blamed as ’emotional’ – the accusation is usually treated the same as a real scandal and people don’t question it. If someone is emotional, is that because they are being bullied, so it becomes a self-fulfilling prophecy? Watch out also for people pressing other people’s buttons, and getting others to do the footwork for them by isolating them. Take a look at these guidelines here and if you are unlucky, you’ll come across someone who does a lot of these behaviours; if so, stay away from them but try to limit their impact on others, too.
On the plus side, the people who let me play in their box are usually wonderful people; they accept me and value me for who I am, and what I bring to the table. I think that this is why my projects are successful; many people discriminate right at the start and I don’t get beyond the starting block so they get partialled out. So it’s only the nice people who see past the five feet two frame and look at how I can help them out.

For the people who do give me a chance, they bless me in all sorts of ways. These people are men and women, cis gendered and transgendered. I’d like to thank all of my customers for being genuine and wonderful.

To summarise, I have less of a ‘range’ to play in, and I have to fight more and longer to get heard, and I have to be ten times as good to get to the same place.

Be brilliant – try your best. Own what you do and love. Then, you’ll be brilliant all by yourself.

 



SQL SERVER – FIX : Msg 35295, Level 16 – Log Backup For Database ‘DBName’ on a Secondary Replica Failed

$
0
0

Once, while doing a load testing with my client, I was shown below error while taking log backups on secondary replica.

Msg 35295, Level 16, State 1, Line 1
Log backup for database “MyAppDB” on a secondary replica failed because the last backup LSN (0x0016ff11:00032258:0001) from the primary database is greater than the current local redo LSN (0x0016ffec:0006ee28:0001). No log records need to be backed up at this time. Retry the log-backup operation later.
Msg 3013, Level 16, State 1, Line 1
BACKUP LOG is terminating abnormally.

This error was interesting because as per documentation we can take backup on the secondary replica in AlwaysOn configuration. I quickly checked AlwaysOn Dashboard from Management studio, all were looking green and databases were synchronized. Then I checked transaction log file (LDF) size and it was very big which made me think in different directions. Went to dashboard again and added Redo queue size. We found that REDO thread was blocked by a user query. As per Sys.dm_exec_requests we found that SPID 28 (which was showing DB STARTUP) was blocked by a user SPID 255. Then we used conventional way and found that SPID 255 was running SELECT INTO query for many hours. This was from a job which had a complex join with huge tables.

WORKAROUND/SOLUTION

If you find the same error while taking log backups on secondary replica, then check REDO THREAD and check if its blocked. Based on criticality you need to take a decision to KILL the SPID which is blocking system SPID.

As soon as we killed user query, the “Recovery Queue” for that database started coming down. Once it came down to zero, we could take a transaction log backup on the secondary.

SQL SERVER - FIX : Msg 35295, Level 16 - Log Backup For Database 'DBName' on a Secondary Replica Failed bos-fail-01-800x379

Have you seen REDO blocked in production environment? Do you monitor this by monitoring tool?

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – FIX : Msg 35295, Level 16 – Log Backup For Database ‘DBName’ on a Secondary Replica Failed

SQL SERVER – Script Upgrade – Server Principal ‘MS_PolicyEventProcessingLogin’ Has Granted One or More Permission(s)

$
0
0

SQL SERVER - Script Upgrade - Server Principal 'MS_PolicyEventProcessingLogin' Has Granted One or More Permission(s) error One should be very careful while working with system objects in SQL Server. Below is one of the situation where some permissions were given on system objects which was causing SQL startup failure. I have written various blog on script upgrade mode of SQL Server.

Whenever a patch is applied to SQL Server, one of the steps after first start is to run upgrade scripts. Those  scripts make changes to system objects. If there is any fatal error in running those scripts, SQL Server would not be able to start.

Below is the ERRORLOG snip from one of the failures.

2017-01-30 17:18:22.44 spid3s Error: 15173, Severity: 16, State: 1.
2017-01-30 17:18:22.44 spid3s Server principal ‘##MS_PolicyEventProcessingLogin##’ has granted one or more permission(s). Revoke the permission(s) before dropping the server principal.
2017-01-30 17:18:22.44 spid3s Error: 912, Severity: 21, State: 2.
2017-01-30 17:18:22.44 spid3s Script level upgrade for database ‘master’ failed because upgrade step ‘msdb110_upgrade.sql’ encountered error 15173, state 1, severity 16. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the ‘master’ database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.
2017-01-30 17:18:22.44 spid3s Error: 3417, Severity: 21, State: 3.
2017-01-30 17:18:22.44 spid3s Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online.

The last message is very scary! We need to look back and look at meaningful error which is 15173 in this case. We should note that ##MS_PolicyEventProcessingLogin## is a certificate-based SQL Server login for internal system use only. It’s created from certificates when SQL Server is installed.

WORKAROUND/SOLUTION

In script failure, we always need to start SQL with trace flag 902, which would cause SQL to skip running those scripts and we get a chance to fix the issue. Here are the steps we followed to start SQL with trace flag.

  • Open SQL Server Configuration Manager
  • Select the SQL server instance in SQL Server Services,
  • Right-click the instance, and then click Properties.
  • Click the Startup Parameter tab.
  • Add “-T902”

Then we started the SQL Server service. Since we have issue with ##MS_PolicyEventProcessingLogin##

SELECT * FROM   sys.server_permissions 
WHERE grantor_principal_id = (SELECT principal_id 
                               FROM sys.server_principals 
                               WHERE NAME = N'##MS_PolicyEventProcessingLogin##')  

Once we ran above query, we found that there was a login having permissions on this login and due to that SQL setup was unable to drop it.

Once we cleared dependency (using the REVOKE command), we were able to remove trace flag and start SQL without any error.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – Script Upgrade – Server Principal ‘MS_PolicyEventProcessingLogin’ Has Granted One or More Permission(s)

My take on presenting

$
0
0
This idea basically started from Andy Bek’s TSQL Tuesday last year #84 growing new speakers (https://sqlbek.wordpress.com/2016/10/25/t-sql-tuesday-84-growing-new-speakers/ – thanks Andy) and I have decided to share my experiences about what was going on in my head for when I was prepping for … Continue reading

SQL DB now supports 4TB max database size

$
0
0

Azure SQL Database (SQL DB) has increased its max database size from 1TB to 4TB at no additional cost.

Customers using P11 and P15 premium performance levels can use up to 4 TB of included storage at no additional charge.  This 4 TB option is currently in public preview in the following regions: US East 2, West US, West Europe, South East Asia, Japan East, Australia East, Canada Central, and Canada East.

When creating a P11/P15, the default storage option of 1TB is pre-selected.  For databases located in one of the supported regions, you can increase the storage maximum to 4TB.  For all other regions, the storage slider cannot be changed.  The price does not change when you select 4 TB of included storage.

For existing P11 and P15 databases located in one of the supported regions, you can increase the maxsize storage to 4 TB.  This can be done in the Azure Portal, in PowerShell or with Transact-SQL.

The 4 TB database maxsize cannot be changed to 1 TB even if the actual storage used is below 1 TB.

Also, available now in preview is a new service tier for Azure SQL Database, called Premium RS, which is designed for IO-intensive workloads where a limited durability guarantee and lower SLA is acceptable in exchange for a cheaper cost.  Target scenarios for Premium RS are developments using in-memory technology, testing high performance workloads, and production analytic workloads.  Premium RS is available for singleton databases and elastic database pools.

More info:

Announcing Azure SQL Database Premium RS, 4TB storage options, and enhanced portal experience

SQL Database options and performance: Understand what’s available in each service tier

SQL SERVER – PRINTing Status Using RAISERROR With NOWAIT Option

$
0
0

In this blog post we are going to learn about PRINTing Status Using RAISERROR With NOWAIT Option.

The Problem 

There are many situations where you want to know which line of code is completed in the batch. Mostly this is a series of commands in SSMS and we want to know where it has reached so far.

SQL SERVER - PRINTing Status Using RAISERROR With NOWAIT Option raiseerror-nowait-800x370

I have seen many using PRINT statement after each statement. But the problem with PRINT statement is that it is not to SSMS unless output buffer is full. I think the buffer size is around 8 KB.

Here is the example of what I mean. You can copy below code in SQL Server Management Studio and run it in text mode to see that output.

PRINT 'SQLAuthority'+ REPLICATE(' ',8000)
PRINT 'Pinal'+ REPLICATE(' ',116)
WAITFOR DELAY '00:00:05'
PRINT 'Final Message'

When we run the code, we can notice that SQLAuthority is printed as soon as we execute the whole code. The Print, which is there is next line, is not printed immediately. The output can only be seen after 5 seconds, when WAIT is complete. I have selected 116 because if I use 115 then both would not be printed because buffer 8K is not full.

Now imagine the same piece of code within a batch where we are doing an insert in tables and we want to know where exactly the code is executing. In that case, we can’t rely on print statement.

The Solution

Here is one of the solution of the above problem.  We can use RAISERROR.

DECLARE @msg1 varchar(max) = 'SQLAuthority'+ REPLICATE(' ',8000)
DECLARE @msg2 varchar(max) = 'Pinal'+ REPLICATE(' ',116)
DECLARE @msg3 varchar(max) ='Final Message'
RAISERROR (@msg1, 0, 1) WITH NOWAIT
RAISERROR (@msg2, 0, 1) WITH NOWAIT
WAITFOR DELAY '00:00:05'
RAISERROR (@msg3, 0, 1) WITH NOWAIT

If we run above code, we can see that first two are printed immediately and then delay of 5 seconds and finally the last message is printed.

As we can see that the RAISERROR method is a much more sophisticated of returning status messages to the client instead of using PRINT.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – PRINTing Status Using RAISERROR With NOWAIT Option

How to Get Status of Running Backup and Restore in SQL Server? – Interview Question of the Week #113

$
0
0

Question: How to Get Status of Running Backup and Restore in SQL Server?

How to Get Status of Running Backup and Restore in SQL Server? - Interview Question of the Week #113 runningbackup-800x362

Answer: One of the reasons I started my blog long ago was to have a repository of scripts which can be very useful by DBA during daily troubleshooting. There are many times when DBA wants to check the progress of a backup or a restore activity which is happening on the server. By combining various commands from the internet, I have come up with below script which can give us a summary of current backups and restores which are happening on the server.

SELECT r.session_id AS [Session_Id]
	,r.command AS [command]
	,CONVERT(NUMERIC(6, 2), r.percent_complete) AS [% Complete]
	,GETDATE() AS [Current Time]
	,CONVERT(VARCHAR(20), DATEADD(ms, r.estimated_completion_time, GetDate()), 20) AS [Estimated Completion Time]
	,CONVERT(NUMERIC(32, 2), r.total_elapsed_time / 1000.0 / 60.0) AS [Elapsed Min]
	,CONVERT(NUMERIC(32, 2), r.estimated_completion_time / 1000.0 / 60.0) AS [Estimated Min]
	,CONVERT(NUMERIC(32, 2), r.estimated_completion_time / 1000.0 / 60.0 / 60.0) AS [Estimated Hours]
	,CONVERT(VARCHAR(1000), (
			SELECT SUBSTRING(TEXT, r.statement_start_offset / 2, CASE 
						WHEN r.statement_end_offset = - 1
							THEN 1000
						ELSE (r.statement_end_offset - r.statement_start_offset) / 2
						END) 'Statement text'
			FROM sys.dm_exec_sql_text(sql_handle)
			))
FROM sys.dm_exec_requests r
WHERE command like 'RESTORE%'
or	command like 'BACKUP%'

Recently I found this script very handy while I was doing performance tuning exercise for a customer. Suddenly we had observed that one of their drives had more I/O and when we ran above script we figured out that there is a backup operation going on the system.

Do you have any similar interesting script which you can share via comments?

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on How to Get Status of Running Backup and Restore in SQL Server? – Interview Question of the Week #113

SQL SERVER – FIX : Error Msg 8672 – The MERGE Statement Attempted to UPDATE or DELETE the Same Row More Than Once

$
0
0

SQL SERVER - FIX : Error Msg 8672 - The MERGE Statement Attempted to UPDATE or DELETE the Same Row More Than Once error While I have been blogging about SQL Server for a long time, I still believe that there is still a lot of error which are not discovered by me. It is always fun to see new error and find a fix for the issue. Let us see how to fix error related to MERGE statement.

Here is one of the errors which I encountered while preparing for a demo.

Msg 8672, Level 16, State 1, Line 19
The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows.

While the error message was telling me the issue, I wanted to know how to avoid it. Here is the sample code which anyone can use and reproduce the same error.

SET NOCOUNT ON
GO
USE tempdb
GO
CREATE TABLE Employee(EmpID INTEGER,EmpName VARCHAR(15) )
GO
INSERT INTO Employee VALUES(1,'Pinal')
INSERT INTO Employee VALUES(2,'SQLServer')
INSERT INTO Employee VALUES(1,'SQLAuthority')
GO 
CREATE TABLE EmployeeSalary (EmpID INTEGER ,Salary INTEGER)
GO
INSERT INTO EmployeeSalary VALUES(1,235)
INSERT INTO EmployeeSalary VALUES(2,255)
GO
MERGE EmployeeSalary AS es
 USING (SELECT EmpID,EmpName FROM Employee) AS m
ON es.EmpID = m.EmpID
WHEN MATCHED THEN
update SET es.Salary = es.Salary + 25;

Looking at the error message, it is clear that the merge statement is trying to update the target table Employee Salary but while doing so, SQL server encountered duplicate entry in the source table (defined as a query)

Hence, here in the table Employee which is the source table in Merge statement, there are two similar entries for EmpID (1) . This tries to update the target the table Employee Salary which has one unique record for this EmpID. Hence this operation is not allowed in Merge and it throws the above error when duplicate entry is seen in the source table (column ref in ON clause in Merge).

WORKAROUND / SOLUTION

To Resolve this issue, we need to remove the duplicate data from the source entities or to prevent such errors from being triggered. We can also create primary key constraints on fields referred in the ON clause of the Merge statement.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – FIX : Error Msg 8672 – The MERGE Statement Attempted to UPDATE or DELETE the Same Row More Than Once


#0402–SQL Server 2016 – KB3207512 fails–Msg 17054 – Unable to shutdown the instance; Operating System Error 21 (The device is not ready)

$
0
0
SQL Server 2016 installations may run into some issues with patching and configuration. This post provides pointers on avoiding these.

Monday Coffee 2017-03-13

$
0
0

Less than a week to go until SQLSaturday Iceland now, it’s going to be a busy couple of months for me but am looking forward to it. I’ll get my slides and demos uploaded here at some point.

I’ve been debating whether or not to do demos live when I’m speaking. In the past I’ve everything live but certain presentations make that a little risky. I’ve done lightening talks where I’ve performed the demo then and there but that’s because I know that the risk of something going wrong is minimal. I’m working on a local instance of SQL and am not depending on anything else (e.g. – an internet connection).

It also depends on what the demo actually is, if it’s code based then running it live means that you can talk about the code but if the code is simple and the demo is more about the process, running it live really doesn’t add anything to the table.

For my session on containers, the demos will be videos. This is in part to reduce the risk of something going wrong but mainly it’s because the code is very simple, what’s happening when I’m running it is what I want to talk about. A video demo means that I don’t have to concentrate on typing the code (you really should never type in demos, copy & paste) and can talk about what’s happening.

Doing it this way will be beneficial as I can focus entirely on the audience and not be staring at my screen. I want to engage with the audience as much as possible and make the session as good as it can be.

Have a good week!


Extreme situations require extreme commands

$
0
0
The title is adapted from a child-hood movie of mine and is my daily (database-related) WTF moment and it is my entry for this month’s T-SQL Tuesday found: http://www.pontop.dk/single-post/2017/03/07/Announcing-T-SQL-Tuesday-88-%E2%80%93-The-daily-database-related-WTF Having a database in Recovery Pending mode is no laughing matter, … Continue reading

SQL SERVER – Errorlog The Server was Unable to Initialize Encryption Because of a Problem with a Security Library

$
0
0

SQL SERVER - Errorlog The Server was Unable to Initialize Encryption Because of a Problem with a Security Library log One of my client was trying to start SQL Service and it was failing. I asked to hare ERRORLOG so that we will get some idea about the cause. Here is the information from ERRORLOG file.

2017-01-31 01:32:25.61 Server The server was unable to initialize encryption because of a problem with a security library. The security library may be missing. Verify that security.dll exists on the system.
2017-01-31 01:32:25.61 spid7s Server name is ‘BIGDBSERVER’. This is an informational message only. No user action is required.
2017-01-31 01:32:25.61 Server Error: 17182, Severity: 16, State: 1.
2017-01-31 01:32:25.61 Server TDSSNIClient initialization failed with error 0x139f, status code 0x80. Reason: Unable to initialize SSL support. The group or resource is not in the correct state to perform the requested operation.
2017-01-31 01:32:25.62 Server Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
2017-01-31 01:32:25.62 Server Error: 17120, Severity: 16, State: 1.
2017-01-31 01:32:25.62 Server SQL Server could not spawn FRunCM thread. Check the SQL Server error log and the Windows event logs for information about possible related problems.

I checked version of SQL Server in ERRORLOG and it was as below.

Microsoft SQL Server 2008 (SP4-OD) (KB3144113) – 10.0.6547.0 (X64)
Feb 22 2016 19:04:50
Copyright (c) 1988-2008 Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (VM)

When I searched for build 10.0.6547, I found below KB. https://support.microsoft.com/en-in/help/3135244/tls-1.2-support-for-microsoft-sql-server

That was a good hint and I checked TLS and SSL registry keys.

WORKAROUND/SOLUTION

I checked below key based on the article

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols

There were no keys for TLS and it means that TLS was not enabled in the server. Either TLS1.0 or SSL3.0 needs to be enabled to start SQL services.

Windows Registry Editor Version 5.00

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0]

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client] “Enabled”=dword:ffffffff
“DisabledByDefault”=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server] “Enabled”=dword:ffffffff
“DisabledByDefault”=dword:00000000

Once we created the keys, we could start SQL Services.

Have you encountered such issues of SQL startup due to TLS? What was the solution you found? Please share by comment to help others.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – Errorlog The Server was Unable to Initialize Encryption Because of a Problem with a Security Library

SQL SERVER – Maintenance Plan – Could not load type ‘Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSPackageSigning100’ from Assembly

$
0
0

SQL SERVER - Maintenance Plan - Could not load type 'Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSPackageSigning100' from Assembly maintenplan One of my client was unable to modify the maintenance plan using SSMS. When we did various tests, we found that existing maintenance plans could execute and work. We tried creating a new maintenance plan and found it to be working.  So, our issue is confined to “unable to modify existing plans”. Here is the error message

Error: Microsoft SQL Server Management Studio is unable to load this document:
Could not load type ‘Microsoft.SQLServer.Dts.Runtime.Wrapper.IDTSPackageSigning100’ from assembly ‘Microsoft.SQLServer.DTSRuntimeWrap.Version=10.0.0.0.Culture=neutral.PublicKey Token=89845dcd8080cc91’.

The error was talking about version 10.0.0.0 and I think it’s the same for SQL 2008 and SQL 2008 R2.

SOLUTION/WORKAROUND

SSMS issue was resolved for my client by installing the right version of shared components. There were 2 instances on this machine; SQL Server 2008 RTM and SQL Server 2008 R2. We uninstalled shared components for the SQL Server RTM and installed shared components from SQL Server 2008 R2 media. After doing the above steps, we could edit the maintenance plans.

Here are a few related blog posts about SQL Server Maitainance Plans:

SQL SERVER – Maintenance Plan fails with 0x80131904 – A network-related or instance-specific error occurred while establishing a connection to SQL Server

SQL SERVER – Using “High Performance” Power Plan for SQL Server

SQL SERVER – Maintenance Plan Folder Missing Under Management in SQL Server Management Studio

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – Maintenance Plan – Could not load type ‘Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSPackageSigning100’ from Assembly

Viewing all 1849 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>