Quantcast
Channel: SQL Archives - SQL Authority with Pinal Dave
Viewing all 594 articles
Browse latest View live

SQL SERVER Analysis Services – Unable to Start Service. Error: The Filename, Directory Name, or Volume Label Syntax is Incorrect

$
0
0

Sometimes I get a chance to work on something which I have not worked earlier but I give my 100% before I give up. This gives me chance to learn something new and every time I get a new topic to write a blog. In this blog, we would learn about fixing “The filename, directory name, or volume label syntax is incorrect” error while starting SQL Server Analysis Services. Here is the exact message from system event log while trying to start the services using configuration manager.

Log Name: Application
Source: MSSQLServerOLAPService
Date: 7/2/2018 7:50:33 AM
Event ID: 0
Task Category: (289)
Level: Error
Keywords: Classic
User: N/A
Computer: SQLAUTHVM1
Description:
The service cannot be started: The following error occurred during a file operation: The filename, directory name, or volume label syntax is incorrect. (\\?\E:).

Here is the exact event which can be seen in the event viewer.

SQL SERVER Analysis Services - Unable to Start Service. Error: The Filename, Directory Name, or Volume Label Syntax is Incorrect ssas-error-01

Notice the path at the end – its “\\?\E:”.

WORKAROUND/SOLUTION

The machine had a drive E:\ so I don’t think that was an issue, but it was a root of the drive, which is unusual. So, I went a step further and copied the command (“Path to Executable” in “Services.msc”) for this service.
“C:\Program Files\Microsoft SQL Server\MSAS14.MSSQLSERVER\OLAP\bin\msmdsrv.exe” -s “C:\Program Files\Microsoft SQL Server\MSAS14.MSSQLSERVER\OLAP\Config”

As expected, I got the same error from command prompt also.

SQL SERVER Analysis Services - Unable to Start Service. Error: The Filename, Directory Name, or Volume Label Syntax is Incorrect ssas-error-02

When I investigated folder “C:\Program Files\Microsoft SQL’ Server\MSAS14.MSSQLSERVER\OLAP\Config” which is picked earlier from services.msc, I found a file “msmdsrv.ini

As I started asking more about this issue, one of the DBA said that they wanted to move the databases to E drive. So, DBA modified msmdsrv.ini and mentioned E drive there. I guess that was the issue.

Below are the bad settings.

SQL SERVER Analysis Services - Unable to Start Service. Error: The Filename, Directory Name, or Volume Label Syntax is Incorrect ssas-error-03

We changed it to a folder on E drive. E:\OLAPDATA and modified settings.

SQL SERVER Analysis Services - Unable to Start Service. Error: The Filename, Directory Name, or Volume Label Syntax is Incorrect ssas-error-04

After this, we were able to start the services. It looks like windows doesn’t allow anyone to write on the root of the drive which is totally fine. I was expecting Access is denied error rather than a confusing error. As they say – All’s well that ends well.

Pinal Dave (https://blog.sqlauthority.com)

First appeared on SQL SERVER Analysis Services – Unable to Start Service. Error: The Filename, Directory Name, or Volume Label Syntax is Incorrect


SQL SERVER – Backup to URL – Script to Generate the Create Credential and Backup Command using Access Keys

$
0
0

Backup to URL is one of the common methods used in SQL Server perform backup to Azure Blob Storage. In this blog, I am going to share a script to generate the create credential and backup command using access keys.

If you don’t know already, Backup to URL also has two methods to connect to the storage account

  1. Credential by using Access Keys.
  2. Credential by using SAS token.

In this blog, I would show the first method – Backup using Access Keys.

WORKAROUND/SOLUTION

To use below script, you need to copy some values from Azure Portal. Go to Azure Portal Home > Storage accounts > Choose Storage account > Access keys as shown below:

SQL SERVER - Backup to URL - Script to Generate the Create Credential and Backup Command using Access Keys Backup-Cred-Script-01

To get a container name, you can refer below screenshot. You need to click on “Browse Blobs”. If you don’t have container created already then click on “+” symbol and create a new one. In my Azure, I have already created one called “dailybackups” as shown below.

SQL SERVER - Backup to URL - Script to Generate the Create Credential and Backup Command using Access Keys Backup-Cred-Script-02

---- Backup To URL (with Credentials) :
--- =================================== ---
DECLARE @Date AS VARCHAR(25)
	,@TSQL AS NVARCHAR(MAX)
	,@ContainerName AS NVARCHAR(MAX)
	,@StorageAccountName AS VARCHAR(MAX)
	,@DatabaseName AS SYSNAME
	,@StorageKey AS NVARCHAR(MAX)
	,@CredentialName AS SYSNAME;
SELECT @StorageAccountName = '';--- Find this from Azure Portal
SELECT @ContainerName = '';--- Find this from Azure Portal
SELECT @StorageKey = '';--- Find this from Azure Portal
SELECT @DatabaseName = 'master';
SELECT @CredentialName = 'Cred' + @StorageAccountName;
IF NOT EXISTS (
		SELECT *
		FROM sys.credentials
		WHERE name = '' + @CredentialName + ''
		)
BEGIN
	SELECT @TSQL = 'CREATE CREDENTIAL [' + @CredentialName + '] WITH IDENTITY = ''' + @StorageAccountName + ''' ,SECRET = ''' + @StorageKey + ''';'
	-- PRINT @TSQL
	EXEC (@TSQL)
END  
SELECT @Date = REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR, GETDATE(), 100), '  ', '_'), ' ', '_'), '-', '_'), ':', '_');
SELECT @TSQL = 'BACKUP DATABASE [' + @DatabaseName + '] TO '
SELECT @TSQL += 'URL = N''https://' + @StorageAccountName + '.blob.core.windows.net/' + @ContainerName + '/' + @DatabaseName + '_' + @Date + '.bak'''
SELECT @TSQL += ' WITH CREDENTIAL = ''' + @CredentialName + ''', COMPRESSION, STATS = 1;'
-- PRINT @TSQL
EXEC (@TSQL)

Above script would create a container and take backup of the master database. Once I ran the script, I could see Credential create and backup was also taken as shown below.

SQL SERVER - Backup to URL - Script to Generate the Create Credential and Backup Command using Access Keys Backup-Cred-Script-03

Here is the backup

SQL SERVER - Backup to URL - Script to Generate the Create Credential and Backup Command using Access Keys Backup-Cred-Script-04

Soon, I would also share a script to use the backup to URL using SAS token via another blog. If you find this useful, please comment and let me know.

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

First appeared on SQL SERVER – Backup to URL – Script to Generate the Create Credential and Backup Command using Access Keys

SQL SERVER – Event ID:7034 – MSSQLSERVER Service Terminated Unexpectedly. It has Done this 6 time(s)

$
0
0

SQL SERVER - Event ID:7034 - MSSQLSERVER Service Terminated Unexpectedly. It has Done this 6 time(s) startup Recently, I came across a strange issue. I noticed that the SQL Server service terminates and restarts automatically and sometimes doesn’t restart and I must manually start it again. In this blog we would learn about Event ID:7034, MSSQLSERVER Service Terminated Unexpectedly.

I referred a lot of online content and they were asking me to refer ERRORLOG. SQL SERVER – Where is ERRORLOG? Various Ways to Find ERRORLOG Location

There was no symptom of SQL Service getting stopped via an external program in ERRORLOG. Looks like it was simply crashing. I checked the System and Application Event log and found below.

Log Name: Application
Source: Windows Error Reporting
Date: 7/7/2018 1:21:53 PM
Event ID: 1001
Task Category: None
Level: Information
Keywords: Classic
User: N/A
Computer: Quick
Description:
Fault bucket 1181302166329499531, type 4
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: sqlservr.exe
P2: 2017.140.3029.16
P3: 5b21dccf
P4: ntdll.dll
P5: 10.0.17134.137
P6: f4df6dc2
P7: c0000005
P8: 00000000000068fc
P9:
P10:

Attached files:
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERACEB.tmp.dmp
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERBA78.tmp.WERInternalMetadata.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERBA99.tmp.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERBAA1.tmp.csv
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERBAF0.tmp.txt
These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_sqlservr.exe_c19c97a3e43677fd3c4956f6194529989c38_21ffaff5_6229c10f

There was no meaningful information in “C:\ProgramData\Microsoft\Windows\WER\ReportArchive\” folder but there were many folders with name AppCrash_sqlserver.exe. As per Quora, 0xC0000005 is a code for Access Violation error. It means that your program just tried to read or write, in a section of memory that it has no access to. Most likely, this happened due to poor usage of pointers.

WORKAROUND/SOLUTION

I had no clue why there was a crash of SQL Service. As per internet reading, the SQL server process might terminate unexpectedly for several reasons.

  • Incorrect program configuration
  • System memory problems
  • Improper license information
  • Missing program files
  • Corrupt user data
  • Severe disk fragmentation.

Once I performed a clean restart of the server, the error didn’t come back again. I am sure it was some rogue process running on the server which got cleared after restart or it might have been some memory corruption. If it comes back again, I think I should report to Microsoft. What do you think? Have you seen this error earlier?

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

First appeared on SQL SERVER – Event ID:7034 – MSSQLSERVER Service Terminated Unexpectedly. It has Done this 6 time(s)

Scalability and Availability Challenges and Shareplex Solutions

$
0
0

If you ask any DBA in the world about their wildest dream, they will always say that want to manage a huge database platform which is scalable whenever it needs to and available always. If you are a DBA, you will agree with the statement. Every DBA who is going home after a day-long work only dreams that a) he does not have to wake up mid-night and b) the first task next day is not to worry about the capacity of the server. Let us learn about Scalability and Availability Challenges and Shareplex Solutions.

In this blog post, we will talk about the subject which directly impacts scalability and available for the database server and in the later part we will see how we can overcome the issues.

Disk Space

If you are familiar with SQL Server, you would know disk space plays a significant role in the overall picture. Let us quickly talk about issues which SQL Server DBA has to face related to disk place.

Log File Growth:

It is essential to keep the database safe all the time, and if any disaster shows up, it is critical to have a database back. Most of the database organizations who care about the safety of their database, they prefer to keep their database in a Full Recovery Mode. When the database is full recovery mode, every single update in the database is logged in the log file. Even if you rebuild indexes or perform any other similar maintenance task, SQL Server will fill up the log.

Auto File Growth:

This particular feature can take many DBAs by surprise. It is a widespread practice that users usually keeps the database file growth at 10% of the database size. If your database size is enormous, and 10% of the file growth is larger than available space on the disk, it is entirely possible that your SQL Server will come to a halt till you free up more space in your SQL Server. The issues with space can be very unpredictable and also quite possibly will catch DBAs with surprise.

Scalability and Availability Challenges and Shareplex Solutions availscal

CPU Resource

Just like disk space, the consumption of the CPU is very unpredictable. If you run a while loop or cursor on your system, you will forsee CPU spike in your database. CPU often struggles with running out of threads when the workload increases beyond the default assigned threads per CPU. Usually, a long queue of the threads leads to eventually timing out queries which wake up DBAs in the night.

It is not essential that our application is available and our database is online, it is equally important that we run our business also efficiently. It is critical for any organization to have the right set of tools when having massive data movement across various database platforms.

Now we have understood the Scalability and Availability Challenges, let us discuss the solution.

SharePlex – A Easily Scalable and Highly Available Solution

We often hear in the industry that disk, memory, and processors are inexpensive and it can be purchased at a fraction of the cost. I agree that hardware resources have been more affordable in the recent time, but they are not unlimited. There is always a capacity how much resources can be available for any system.

It is sometimes challenging to upgrade the hardware of one system and run our system efficiently. The best possible solution that case would be to scale the hardware and build a high availability solution.

Here is the where I suggest SharePlex to my customers. It is a unique solution which replicates data from one database platform to another database platform.

Here are few of the essential features of SharePlex

  • It is database vendor agnostic making it work with pretty much works with most of the popular database platforms like SQL Server, Oracle, Amazon Web Services (AWS), AuroraDB, Azure SQL Database service, EDB Postgres Advanced Server, Java Message Service (JMS), MySQL, PostgreSQL, SAP ASE, SAP HANA, Oracle, Microsoft SQL Server, Teradata,Tibero, Kafka, and flat, SQL and XML files.
  • It supports near real-time data integration and replication which comes out very handy when you are resource stripped and want to keep your system running smoothly and efficiently.

Here is the next action for you – Download Free Trial of SharePlex and validate it for your application. As I said earlier the best part of this product is that it replicates data in any environment which helps you to scale immediately and keep your database highly available.

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

First appeared on Scalability and Availability Challenges and Shareplex Solutions

SQL SERVER – Msg 3292: A Failure Occurred While Attempting to Execute Backup or Restore With a URL Device Specified

$
0
0

SQL SERVER - Msg 3292: A Failure Occurred While Attempting to Execute Backup or Restore With a URL Device Specified errorbackup In my recent project with a customer, they wanted to configure SQL backups to Azure Blob Storage. When we were trying to take a backup, we were facing error. In this blog we would learn how to fix error message 3292 – A failure occurred while attempting to execute Backup or Restore with a URL device specified.

The command which we tried was below

BACKUP DATABASE master TO URL = 'https://sqldbprodbackups.blob.core.windows.net/daily/master.bak'
WITH CREDENTIAL = 'BackupCredential'
GO

Here was the error which we were seeing.

Msg 3292, Level 16, State 6, Line 1
A failure occurred while attempting to execute Backup or Restore with a URL device specified. Consult the operating system error log for details.
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.

We have checked and verified that same command works from another server and backup works fine. That means the issue was not with the storage account. I found below MSDN link to troubleshoot the issue.

SQL Server Backup to URL Best Practices and Troubleshooting

As per above, I enabled trace flag 3051 to get more detailed messages.

DBCC TRACEON (3051,3605,-1);
GO

After this, I ran the backup command again and here is the information I received in the ERRORLOG file

2018-07-04 20:52:20.83 spid65 DBCC TRACEON 3051, server process ID (SPID) 65. This is an informational message only; no user action is required.
2018-07-04 20:52:20.83 spid65 DBCC TRACEON 3605, server process ID (SPID) 65. This is an informational message only; no user action is required.
2018-07-04 20:52:23.37 spid65 VDI: “C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Binn\BackupToUrl.exe” “b” “p” “xxxx” “yyyy” “zzzz” “NOFORMAT” “4D005300530051004C00530045005200560045005200” “C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Log” “DB” “6D0061007300740065007200” “TRACE”
2018-07-04 20:52:23.37 spid65 BackupToUrl: couldn’t load process Error Code: 80070002
2018-07-04 20:52:23.37 Backup Error: 3041, Severity: 16, State: 1.
2018-07-04 20:52:23.37 Backup BACKUP failed to complete the command BACKUP DATABASE master. Check the backup application log for detailed messages.

I have truncated messages to fit into the blog, instead of xxx, yyy and zzz there were long strings. Did we see anything interesting? Below is an interesting message.

BackupToUrl: couldn’t load process Error Code:  80070002

WORKAROUND/SOLUTION

You can use my earlier blog to convert above code to a meaningful and human-readable error message.

How to Convert Hex Windows Error Codes to the Meaningful Error Message – 0x80040002 and 0x80040005 and others?

As per code, it means “The system cannot find the file specified.”. When I checked BINN folder we found that someone renamed BackupToUrl.exe to BackupToUrl.exe.dll

Once we renamed the file back to original name, the backup started working fine.

Here is the command to turn off the trace flag.

DBCC TRACEOFF (3051,3605,-1);
GO 

Have you used any other trace flag for troubleshooting backup/restore issue?

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

First appeared on SQL SERVER – Msg 3292: A Failure Occurred While Attempting to Execute Backup or Restore With a URL Device Specified

SQL SERVER – Backup to URL – Script to Generate Credential and Backup using Shared Access Signature (SAS)

$
0
0

As I mentioned in my earlier blog, backup to URL is one of the common methods used in SQL Server performs a backup to Azure Blob Storage. In this blog, I am going to share a script to generate the create credential and backup command using Shared Access Signature also called as SAS token.

If you don’t know already, Backup to URL also has two methods to connect to the storage account

  1. Credential by using Access Keys.
  2. Credential by using SAS token.

In my earlier blog, I have shared script to use the first method. SQL SERVER – Msg 3292: A Failure Occurred While Attempting to Execute Backup or Restore With a URL Device Specified

In this blog, I would show the second method – Backup using Shared Access Signature.

WORKAROUND/SOLUTION

In the script, we need to provide below parameters.

  1. @StorageAccountName: In Azure portal, go to “Home” > “Storage accounts” and pick up the account which you want to use. In my demo, its “sqldbprodbackups”.
  2. @ContainerName: To get a container name, you can refer below screenshot. You need to click on “Browse Blobs”. If you don’t have container created already then click on “+” symbol and create a new one. In my Azure, I have already created one called “dailybackups” as shown below. You can also see @StorageAccountName on the same page.

SQL SERVER - Backup to URL - Script to Generate Credential and Backup using Shared Access Signature (SAS) Backup-SAS-Script-01

  1. @SASKey: Refer below steps for SAS Key generation.

We need to click on “Shared access signature” as shown below.

SQL SERVER - Backup to URL - Script to Generate Credential and Backup using Shared Access Signature (SAS) Backup-SAS-Script-02

Then we need to click on “Generate SAS and connection string” button. Once done, scroll down and we should see something like below.

SQL SERVER - Backup to URL - Script to Generate Credential and Backup using Shared Access Signature (SAS) Backup-SAS-Script-03

The value should be assigned to variable @SASKey

---- Backup To URL (using SAS Token) :
--- =================================== --- 
DECLARE @Date AS NVARCHAR(25)
	,@TSQL AS NVARCHAR(MAX)
	,@ContainerName AS NVARCHAR(MAX)
	,@StorageAccountName AS VARCHAR(MAX)
	,@SASKey AS VARCHAR(MAX)
	,@DatabaseName AS SYSNAME;
SELECT @Date = REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR, GETDATE(), 100), '  ', '_'), ' ', '_'), '-', '_'), ':', '_');
SELECT @StorageAccountName = ''; --- Find this from Azure Portal
SELECT @ContainerName = ''; --- Find this from Azure Portal
SELECT @SASKey = ''; --- Find this from Azure Portal
SELECT @DatabaseName = 'master';
IF NOT EXISTS (
		SELECT *
		FROM sys.credentials
		WHERE name = '''https://' + @StorageAccountName + '.blob.core.windows.net/' + @ContainerName + ''''
		)
BEGIN
	SELECT @TSQL = 'CREATE CREDENTIAL [https://' + @StorageAccountName + '.blob.core.windows.net/' + @ContainerName + '] WITH IDENTITY = ''SHARED ACCESS SIGNATURE'', SECRET = ''' + REPLACE(@SASKey, '?sv=', 'sv=') + ''';'
	--SELECT @TSQL
	EXEC (@TSQL)
END
SELECT @TSQL = 'BACKUP DATABASE [' + @DatabaseName + '] TO '
SELECT @TSQL += 'URL = N''https://' + @StorageAccountName + '.blob.core.windows.net/' + @ContainerName + '/' + @DatabaseName + '_' + @Date + '.bak'''
SELECT @TSQL += ' WITH COMPRESSION, MAXTRANSFERSIZE = 4194304, BLOCKSIZE = 65536, CHECKSUM, FORMAT, STATS = 1;'
--SELECT @TSQL
EXEC (@TSQL)

Once the script was executed, we could see credential in SSMS and backup in Azure.

SQL SERVER - Backup to URL - Script to Generate Credential and Backup using Shared Access Signature (SAS) Backup-SAS-Script-04

SQL SERVER - Backup to URL - Script to Generate Credential and Backup using Shared Access Signature (SAS) Backup-SAS-Script-05

Hope this would help you in creating the script in an easier way.

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

First appeared on SQL SERVER – Backup to URL – Script to Generate Credential and Backup using Shared Access Signature (SAS)

SQL SERVER – Backup to URL – Script to Perform Stripped Backup using Shared Access Signature (SAS)

$
0
0

Here are my previous blogs about Backup to URL, I have share scripts to take backup using Access Keys and SAS Token. One of my blog readers wanted to take stripped backup to Azure Blob. In this blog, I am sharing the script to perform a stripped backup using shared access signature (SAS Token)

SQL SERVER – Backup to URL – Script to Generate Credential and Backup using Shared Access Signature (SAS)
SQL SERVER – Msg 3292: A Failure Occurred While Attempting to Execute Backup or Restore With a URL Device Specified

WORKAROUND/SOLUTION

In this script, I am assuming that we already have credential created using an earlier blog. You need to provide is @StorageAccountName, @ContainerName, @DatabaseName and @NumberOfFiles which you need for striping. You can refer my earlier blogs to find those details from the Azure portal.

---- Backup To URL (using SAS Token and striping) :
--- =================================== --- 
DECLARE @Date AS NVARCHAR(25)
	,@TSQL AS NVARCHAR(MAX)
	,@ContainerName AS NVARCHAR(MAX)
	,@StorageAccountName AS VARCHAR(MAX)
	,@SASKey AS VARCHAR(MAX)
	,@DatabaseName AS SYSNAME
	,@NumberOfFiles AS INTEGER
	,@temp_Count AS INTEGER = 1;
SELECT @Date = REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR, GETDATE(), 100), '  ', '_'), ' ', '_'), '-', '_'), ':', '_');
SELECT @StorageAccountName = 'sqldbprodbackups'; --- Find this from Azure Portal
SELECT @ContainerName = 'dailybackups'; --- Find this from Azure Portal
SELECT @DatabaseName = 'master';
SELECT @NumberOfFiles = 5;-- Greater than 1
SELECT @TSQL = 'BACKUP DATABASE [' + @DatabaseName + '] TO '
WHILE @temp_Count <= @NumberOfFiles
BEGIN
	IF (@temp_Count != @NumberOfFiles)
	BEGIN
		SELECT @TSQL += 'URL = N''https://' + @StorageAccountName + '.blob.core.windows.net/' + @ContainerName + '/' + @DatabaseName + '_' + @Date + '_File_' + CONVERT(VARCHAR(10), @temp_Count) + '_of_'+ CONVERT(VARCHAR(10), @NumberOfFiles) + '.bak'','
	END
	ELSE
	BEGIN
		SELECT @TSQL += 'URL = N''https://' + @StorageAccountName + '.blob.core.windows.net/' + @ContainerName + '/' + @DatabaseName + '_' + @Date + '_File_' + CONVERT(VARCHAR(10), @temp_Count) + '_of_'+ CONVERT(VARCHAR(10), @NumberOfFiles) + '.bak'''
	END
	SET @temp_Count = @temp_Count + 1
END
SELECT @TSQL += ' WITH COMPRESSION, MAXTRANSFERSIZE = 4194304, BLOCKSIZE = 65536, CHECKSUM, FORMAT, STATS = 1;'
--SELECT (@TSQL)
EXEC (@TSQL)
--- =================================== ---

As soon as the backup is complete, I could see 5 files in the blog storage, that means the script is working as expected.

SQL SERVER - Backup to URL - Script to Perform Stripped Backup using Shared Access Signature (SAS) sas-stripped-backup-01

Hope this script would someone who wants to strip automated backup. Feel free to modify and use it. Let me know if you have other scripts which you use. Share with the world via the comments section.

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

First appeared on SQL SERVER – Backup to URL – Script to Perform Stripped Backup using Shared Access Signature (SAS)

SQL SERVER – Backup Error: 3636 – An Error Occurred While Processing BackupMetadata

$
0
0

SQL SERVER - Backup Error: 3636 - An Error Occurred While Processing BackupMetadata errorbackup Recently one of my old clients contacted me and informed that they are having an issue with database backup on the secondary replica. In this blog we would learn about how to fix error 3636 – An error occurred while processing BackupMetadata.

I have provided consultancy to this customer to deploy Always On Availability Group. We have designed backups in such a way that log backup happens on the secondary replica. This was working well but suddenly they started seeing this error.

An error occurred while processing ‘BackupMetadata’ metadata for database id 11 file id 1. [SQLSTATE 42000] (Error 3636)
Inconsistent metadata has been encountered. The only possible backup operation is a tail-log backup using the WITH CONTINUE_AFTER_ERROR or NO_TRUNCATE option.

Above error has two error messages.

  1. Error 3636 – An error occurred while processing ‘%ls’ metadata for database id %d file id %d.
  2. Error 3046 – Inconsistent metadata has been encountered. The only possible backup operation is a tail-log backup using the WITH CONTINUE_AFTER_ERROR or NO_TRUNCATE option.

I asked more about the background of the issue and history. The had an interesting situation. One of the available databases showed enormous growth in the LDF file and they went ahead and added a new drive and additional file to mitigate the situation. This huge transaction was unavoidable for their business. When we looked at timings, we found that backup failure started after adding a new LDF file on the primary.

When I checked sys.master_files on primary and secondary, it was clear that secondary didn’t have the file yet. This was because the huge transaction was still getting replayed on the secondary replica. The REDO queue size of around 500 GB.

WORKAROUND/SOLUTION

The error message appeared because the transaction which added the new file on primary replica didn’t apply yet on the secondary. We waited for redo queue to drain on this replica. As soon as we saw the same information about the files in the database, the log backup executed fine.

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

First appeared on SQL SERVER – Backup Error: 3636 – An Error Occurred While Processing BackupMetadata


SQL SERVER – Installation Error: The Specified Value ‘Install’ for ACTION is Invalid

$
0
0

I was helping a client to install SQL Server using script/automation (without using UI). They wanted to do command-line install rather than hitting next, next, fill values in the UI as they have to deploy more than 100 servers with SQL installed on it. In this blog we would learn about how to fix SQL Setup installation error – “The specified value ‘Install’ for ACTION is invalid.”

When my client first contacted me, they just told the error and as always, I asked for the setup log file. I had no idea how they were installing it. When I investigated the setup bootstrap log file, here is what I saw:

Overall summary:
Final result: Failed: see details below
Exit code (Decimal): -2057043952
Exit facility code: 1380
Exit error code: 16
Exit message: The specified value ‘Install’ for ACTION is invalid. To run in unattended mode, you must specify a valid ACTION. The valid values for ACTION are: None RemovePatch Uninstall Install Upgrade Patch Repair LandingPage ClusterReport RunRules PrepareFailoverCluster CompleteFailoverCluster InstallFailoverCluster RemoveNode AddNode EditionUpgrade Bootstrap ComponentUpdate Help RebuildDatabase RunDiscovery PrepareImage CompleteImage ConfigureImage
Start time: 2018-07-12 17:05:33
End time: 2018-07-12 17:05:35
Requested action: None

When I looked further in the log, I could see below:

User Input Settings:
ACTION: None
CONFIGURATIONFILE:
ENU: false
HELP: false
IACCEPTPYTHONLICENSETERMS: false
IACCEPTROPENLICENSETERMS: false
INDICATEPROGRESS: false
MRCACHEDIRECTORY:
QUIET: false
QUIETSIMPLE: false
SUPPRESSPRIVACYSTATEMENTNOTICE: false
UIMODE: Normal
X86: false

After few lines, I found this.

WatsonData = Microsoft.SqlServer.Chainer.Infrastructure.InvalidWorkflowException@16
DisableWatson = true
Stack:
at Microsoft.SqlServer.Chainer.Infrastructure.InputSettingService.SaveInputSettingValueToObjectEnum(
at Microsoft.SqlServer.Chainer.Infrastructure.InputSettingService.SaveParsedArgumentsIntoSettings(
at Microsoft.SqlServer.Configuration.BootstrapExtension.ProcessChainerCommandLineArgumentsAction.ExecuteAction(
at Microsoft.SqlServer.Chainer.Infrastructure.Action.Execute(
at Microsoft.SqlServer.Setup.Chainer.Workflow.ActionInvocation.<>c__DisplayClasse.b__b(
at Microsoft.SqlServer.Setup.Chainer.Workflow.ActionInvocation.ExecuteActionHelper(
Inner exception type: System.ArgumentException
Message:
Requested value ”Install” was not found.
HResult : 0x80070057
Stack:
at System.Enum.EnumResult.SetFailure(
at System.Enum.TryParseEnum(
at System.Enum.Parse(

This was strange because not many parameters are visible in the first section and then I see (notice two single quotes)

Requested value ”Install” was not found.

I asked them a screenshot of the error and they share below with me:

SQL SERVER - Installation Error: The Specified Value 'Install' for ACTION is Invalid install-cmd-err-01

WORKAROUND/SOLUTION

After this, I realize that due to single quotes around Install action, setup is parsing it incorrectly and thinking ‘install’ as an action. I checked the documentation and indeed single quotes for a parameter value is not valid.

Once we replace the single quote with a double quote on the command prompt, setup moved forward but there was a new error, which I would blog later.

Have you faced similar issue earlier?

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

First appeared on SQL SERVER – Installation Error: The Specified Value ‘Install’ for ACTION is Invalid

SQL SERVER – Install Error: Validation for Setting ‘AGTSVCACCOUNT’ Failed. Error Message: The RPC Server is Unavailable

$
0
0

During my consultancy engagement, my client’s DBA team was installing SQL Server and getting an error. Since they know my work style, I got pulled into fixing that issue. In this blog, we would learn how to fix SQL installation error: Validation for setting ‘AGTSVCACCOUNT’ failed. Error message: The RPC server is unavailable.

As I mentioned above, they were using command line-based installation. So, my first plan was action was – show me the setup log and look for the exact error. If you don’t know the trick to look at setup logs, you should know that you need to look at Detail.txt and search for “at Microsoft”. Once found, then look few lines above and you should find some error. Here is what I saw in their setup log.

Slp: Validation for setting ‘AGTSVCACCOUNT’ failed. Error message: The RPC server is unavailable.
Slp: Validation for setting ‘ISSVCAccount’ failed. Error message: The credentials you provided for the Integration Services service are invalid. To continue, provide a valid account and password for the Integration Services service.
Slp: Validation for setting ‘SQLSVCACCOUNT’ failed. Error message: The SQL Server service account login or password is not valid. Use SQL Server Configuration Manager to update the service account.
Slp: Error: Action “Microsoft.SqlServer.Configuration.SetupExtension.ValidateFeatureSettingsAction” threw an exception during execution.
Slp: Microsoft.SqlServer.Setup.Chainer.Workflow.ActionExecutionException: The RPC server is unavailable.
Slp: —> Microsoft.SqlServer.Chainer.Infrastructure.InputSettingValidationException: The RPC server is unavailable.
Slp: —> Microsoft.SqlServer.Configuration.Agent.InputValidationException: The RPC server is unavailable.

WORKAROUND/SOLUTION

As soon as I saw the error- “The RPC server is unavailable” while validating domain account, I realized that I have seen this error earlier. It didn’t take much time for me to find this on my own blog.

SQL SERVER – Installation Wizard Hangs at Service Account Page – The RPC Server is Unavailable

Looks like Microsoft has fixed the “hang” issue which I blogged earlier. But the solution was the same which worked for this client also. We followed the same steps as mentioned in my blog and found that they missed using FQDN for the domain controller. Instead, they gave an only partial name.

SQL SERVER - Install Error: Validation for Setting 'AGTSVCACCOUNT' Failed. Error Message: The RPC Server is Unavailable RPCSetup-err-01

As you can see the image, we opened network connections and went to properties on domain network adapter and went all the way down to DNS tab to fix the suffix. You need to click on all the numbered circles in sequence.

Once we fixed DNS suffix, the setup worked like a charm.

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

First appeared on SQL SERVER – Install Error: Validation for Setting ‘AGTSVCACCOUNT’ Failed. Error Message: The RPC Server is Unavailable

SQL SERVER – Error 9002: The Transaction Log for Database ‘SQLDB’ is Full Due to ‘DATABASE_MIRRORING’

$
0
0

It is interesting to see in SQL Server that same error message is raised due to multiple reasons. One such error is 9002. In this blog, we would quickly learn about the cause of error 9002: The transaction log for database ‘SQLDB’ is full due to ‘DATABASE_MIRRORING’

In earlier versions of SQL Server, the error message 9002 was not very informative. This was the message earlier.

The transaction log for database ‘Database_Name’ is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases.

In my opinion, it was a less useful message because it doesn’t tell the cause. If you ask any DBA why log file is full, they won’t be able to tell all the possible reasons. Here is the complete list as of today from books online. Here are the various values which can be seen in log_reuse_wait_desc in sys.databases catalog view.

  • LOG_BACKUP
  • ACTIVE_BACKUP_OR_RESTORE
  • ACTIVE_TRANSACTION
  • DATABASE_MIRRORING
  • REPLICATION
  • DATABASE_SNAPSHOT_CREATION
  • LOG_SCAN
  • AVAILABILITY_REPLICA
  • OLDEST_PAGE

In the current version of SQL Server, the text of error number 9002 is as below:

The transaction log for database ‘%ls’ is full due to ‘%ls’.

As we can see there are two placeholders, database name and the reason. In my client’s database it was DATABASE_MIRRORING.

WORKAROUND/SOLUTION

Based on the reason in the error message, we need to take action. In my client’s server, the database was configured for database mirroring but due to some reason mirror server was not able to come in sync with the principal server. So, the quickest way to get free space on the principal database was to break the mirroring and remove mirror server for this database.

ALTER DATABASE SQLDB SET PARTNER OFF

If you want to use UI and able to open database properties, then you can go to “Database Mirroring” page and choose “Remove Mirroring” as shown below.

SQL SERVER - Error 9002: The Transaction Log for Database 'SQLDB' is Full Due to 'DATABASE_MIRRORING' err-9002-miror-01

After this, we restarted SQL and database came online successfully.

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

First appeared on SQL SERVER – Error 9002: The Transaction Log for Database ‘SQLDB’ is Full Due to ‘DATABASE_MIRRORING’

SQL SERVER – Database Mirroring Login Attempt Failed With Error: ‘Connection Handshake Failed. An OS Call Failed: (80090350)

$
0
0

SQL SERVER - Database Mirroring Login Attempt Failed With Error: 'Connection Handshake Failed. An OS Call Failed: (80090350) warning While Microsoft has introduced an AlwaysOn availability group feature in SQL Server 2012 and people have been using it instead of database mirroring. In this blog, we would learn how to fix error Database Mirroring login attempt failed with error: ‘Connection handshake failed. An OS call failed: (80090350).

When they contacted me, the situation was that the primary replica was showing secondary in a disconnected state. When I asked to check SQL Server ERRORLOG, we found below on secondary replica.

Database Mirroring login attempt failed with error: ‘Connection handshake failed. An OS call failed: (80090350) 0x80090350(The system cannot contact a domain controller to service the authentication request. Please try again later.). State 66.’. [SERVER: 10.xx.xx.xx]

The IP address which is at the end of the error message was the IP address of the primary replica. One of the interesting things about error message is that even though they were not using database mirroring the error message was saying -“Database Mirroring Login”. I think this is because of the fact that the endpoint is same for availability group and mirroring.

WORKAROUND/SOLUTION

I asked more about how they landed up in this situation. They informed me that there were some network issues. Their network team fixed the issue but right now, they have an issue, where the mirror server is not able to get in sync with the principal and LDF file, is growing.

I have an existing blog on the same error message. SQL SERVER – Database Mirroring login attempt failed – Connection handshake failed

In our case hexadecimal code was different. It is 0x80090350. I used COM Error Codes (Security and Setup) and it says SEC_E_DOWNGRADE_DETECTED – The system cannot contact a domain controller to service the authentication request. Please try again later. That is the message which we are seeing ERRORLOG as well. So, we are in the right direction.

We were able to log in to SQL using Windows accounts on the mirror server. We were also able to ping domain controller. I asked them to restart the machine so that it re-establishes the connection to the domain controller. Since it was a secondary replica, there were no problems in rebooting it. As expected, it worked for them and after the restart, the replicas were able to talk to each other and AlwaysOn started working.

Have you ever encountered such cryptic errors?

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

First appeared on SQL SERVER – Database Mirroring Login Attempt Failed With Error: ‘Connection Handshake Failed. An OS Call Failed: (80090350)

SQL SERVER – Unable to Load User-Specified Certificate [Cert Hash(sha1) “Thumbprint.here”]. The Server Will Not Accept a Connection

$
0
0

While preparing for a security demo, I broke my SQL Server and was unable to start it. In this blog, we would lean about fixing error Unable to load user-specified certificate.

Whenever I run into SQL startup trouble, I always start from SQL Server ERRORLOG.

SQL SERVER – Where is ERRORLOG? Various Ways to Find ERRORLOG Location

Here are the messages at the end of the ERRORLOG file.

2018-08-04 14:21:46.02 Server Error: 26014, Severity: 16, State: 1.
2018-08-04 14: 21:46.02 Server Unable to load user-specified certificate [Cert Hash(sha1) "73EF12.thumbprint.here.CA8DE"]. The server will not accept a connection. You should verify that the certificate is correctly installed. See "Configuring Certificate for Use by SSL" in Books Online.
2018-08-04 14:21:46.02 Server Error: 17182, Severity: 16, State: 1.
2018-08-04 14:21:46.02 Server TDSSNIClient initialization failed with error 0x80092004, status code 0x80. Reason: Unable to initialize SSL support. Cannot find object or property.

From the message we can see that there is something wrong with the certificate which I was using to start SQL Service. In the past, I have faced the same issue and I knew what needs to be done. Here is the registry key which stored thumbprint of the certificate

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.<Version>\InstanceName\MSSQLServer\SuperSocketNetLib\Certificate

The value of <Version> would be dependent on SQL Server version:

MSSQL10 SQL Server 2008
MSSQL10_50 SQL Server 2008 R2
MSSQL11 SQL Server 2012
MSSQL12 SQL Server 2014
MSSQL13 SQL Server 2016
MSSQL14 SQL Server 2017

And you need to know the Instance name to reach to the right key. In below screenshot, I am showing key for SQL Server 2016 (MSSQL14) and Default Instance (MSSQLSERVER)

SQL SERVER - Unable to Load User-Specified Certificate [Cert Hash(sha1) "Thumbprint.here"]. The Server Will Not Accept a Connection cert-thumb-err-01

WORKAROUND/SOLUTION

If you are not using certificate, then you can rename “Certificate” to “Old_Certificate” and created a new entry (REG_SZ) called Certificate with no value (blank).  After doing so SQL Server should successfully.

If you are using certificate, then don’t play with that key. One other possible reason for such error while using certificate is that the SQL Server Service account doesn’t have full permission on Certificate private key. To fix this issue, you need to right-click on the certificate and in manage private key, grant full permission to SQL Server service account.

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

First appeared on SQL SERVER – Unable to Load User-Specified Certificate [Cert Hash(sha1) “Thumbprint.here”]. The Server Will Not Accept a Connection

SQL SERVER – Setting ARITHABORT ON for All Connecting .Net Applications

$
0
0

Readers of this blog post are aware of SQL Server Expert Tim Cartwright, who has previously written an enhanced version of How to Generate Random Password script. Here is another very interesting find by Tim on the subject of ARITHABORT ON setting. It is one of the most interesting blog post I have read in a while.

SQL SERVER - Setting ARITHABORT ON for All Connecting .Net Applications ARITHABORT0

Information

Many people have blogged in the past how having ARITHABORT OFF in your connection settings can adversely affect your query performance and produce bad plans. Erland Sommarskog has a very well written article: Slow in the Application, Fast in SSMS?. My co-worker Daniel Berber was mentioned in this article alerting Erland to the face that ARITHABORT should always be on. Tara Kizer talks about it in this article: Troubleshooting Parameter Sniffing Issues the Right Way: Part 2.

Even Microsoft’s own documentation stresses this should always be ON. Quote from MSDN:

Remarks

You should always set ARITHABORT to ON in your logon sessions. Setting ARITHABORT to OFF can negatively impact query optimization leading to performance issues.

Warning

The default ARITHABORT setting for SQL Server Management Studio is ON. Client applications setting ARITHABORT to OFF can receive different query plans making it difficult to troubleshoot poorly performing queries. That is, the same query can execute fast in management studio but slow in the application. When troubleshooting queries with Management Studio always match the client ARITHABORT setting.

We could try to edit all of our applications and work with our developers to turn ARTIHABORT on every time they connect but that would be incredibly troublesome. It would also be pretty much impossible for any 3rd party applications where we do not have control over the code.  Fortunately for us, there is an easier way.

WARNING: Before continuing, be very aware that you are changing a server-wide setting that affects all of the .Net connections to that server. Like any global setting you should test and monitor to verify that nothing breaks preferably on a non-production server. I don’t think there is a chance that this will happen, but I still need to warn you. Also, be very careful about setting the other settings globally as you can cause some serious problems with queries. Especially with a setting like NUMERIC_ROUNDABORT.

Here is the script which checks the settings of various set options.

/*
Author: Tim Cartwright
Purpose: Allows you to check the server, and client SET options
https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-user-options-server-configuration-option
1 DISABLE_DEF_CNST_CHK Controls interim or deferred constraint checking.
2 IMPLICIT_TRANSACTIONS For dblib network library connections, controls whether a transaction is started implicitly when a statement is executed. The IMPLICIT_TRANSACTIONS setting has no effect on ODBC or OLEDB connections.
4 CURSOR_CLOSE_ON_COMMIT Controls behavior of cursors after a commit operation has been performed.
8 ANSI_WARNINGS Controls truncation and NULL in aggregate warnings.
16 ANSI_PADDING Controls padding of fixed-length variables.
32 ANSI_NULLS Controls NULL handling when using equality operators.
64 ARITHABORT Terminates a query when an overflow or divide-by-zero error occurs during query execution.
128 ARITHIGNORE Returns NULL when an overflow or divide-by-zero error occurs during a query.
256 QUOTED_IDENTIFIER Differentiates between single and double quotation marks when evaluating an expression.
512 NOCOUNT Turns off the message returned at the end of each statement that states how many rows were affected.
1024 ANSI_NULL_DFLT_ON Alters the session's behavior to use ANSI compatibility for nullability. New columns defined without explicit nullability are defined to allow nulls.
2048 ANSI_NULL_DFLT_OFF Alters the session's behavior not to use ANSI compatibility for nullability. New columns defined without explicit nullability do not allow nulls.
4096 CONCAT_NULL_YIELDS_NULL Returns NULL when concatenating a NULL value with a string.
8192 NUMERIC_ROUNDABORT Generates an error when a loss of precision occurs in an expression.
16384 XACT_ABORT Rolls back a transaction if a Transact-SQL statement raises a run-time error.
*/
DECLARE @options TABLE ([name] nvarchar(35), [minimum] int, [maximum] int, [config_value] int, [run_value] int)
DECLARE @optionsCheck TABLE([id] int NOT NULL IDENTITY, [setting_name] varchar(128))
DECLARE @current_value INT;
INSERT INTO @options ([name], [minimum], [maximum], [config_value], [run_value])
EXEC sp_configure 'user_options';
SELECT @current_value = [config_value] FROM @options;
--SELECT name, minimum, maximum, config_value, run_value FROM @options
--SELECT @current_value
INSERT INTO @optionsCheck
([setting_name])
VALUES
('DISABLE_DEF_CNST_CHK'),
('IMPLICIT_TRANSACTIONS'),
('CURSOR_CLOSE_ON_COMMIT'),
('ANSI_WARNINGS'),
('ANSI_PADDING'),
('ANSI_NULLS'),
('ARITHABORT'),
('ARITHIGNORE'),
('QUOTED_IDENTIFIER'),
('NOCOUNT'),
('ANSI_NULL_DFLT_ON'),
('ANSI_NULL_DFLT_OFF'),
('CONCAT_NULL_YIELDS_NULL'),
('NUMERIC_ROUNDABORT'),
('XACT_ABORT')
SELECT fn.[value],
oc.[setting_name],
[server_option] = CASE WHEN (@current_value &amp; fn.[value]) = fn.[value] THEN 'ON' ELSE '-' END,
[client_option] = CASE WHEN (@@options &amp; fn.[value]) = fn.[value] THEN 'ON' ELSE '-' END
FROM @optionsCheck oc
CROSS APPLY (
SELECT [value] = CASE WHEN oc.id &gt; 1 THEN POWER(2, oc.id - 1) ELSE 1 END
) fn

Checking the current value of ARITHABORT

Most people believe that SSMS has ARITHABORT ON by default, and all connections made from .net always have set it to OFF. Well as it turns out that is not quite true. The .net SQL server driver connects to the SQL Server and queries what the server settings are and uses those for the connection session. How do I see what my current settings are? You can run EXEC sp_configure ‘user_options’; and you should see results like this:

SQL SERVER - Setting ARITHABORT ON for All Connecting .Net Applications ARITHABORT1

The config_value and the run_value show the currently set values for the set options which are a bitmask. Bit masking is outside of the scope of this article, but suffice it to say that it allows SQL Server to store many true-false values with one integer value.

A config_value of 0 means that basically none of the SET options are altered, and .net connections will use their own defaults. We can verify that the ARTIHABORT setting is off on the server by running this script:

/* TEST FOR ARITHABORT ON */
DECLARE @options TABLE ([name] nvarchar(35), [minimum] int, [maximum] int, [config_value] int, [run_value] int);
INSERT INTO @options ([name], [minimum], [maximum], [config_value], [run_value])
EXEC sp_configure 'user_options';
SELECT [setting] = 'ARITHABORT ' + CASE WHEN ([config_value] & 64) = 64 THEN 'ON' ELSE 'OFF' END
FROM @options;
GO

Results:

SQL SERVER - Setting ARITHABORT ON for All Connecting .Net Applications ARITHABORT2

Before we turn it on, we can check to see what setting applications are using when connecting by running the below PowerShell script from Windows PowerShell ISE (Change the ServerInstance):

Clear-Host
Invoke-Sqlcmd2 -ServerInstance "(local)" -Database "master" -Query "SELECT [Setting] = 'ARITHABORT ' + CASE WHEN (@@options & 64) = 64 THEN 'ON' ELSE 'OFF' END"

We should see this as a result:

Setting
——-
ARITHABORT OFF

Why is it OFF by default? Well, that is because like most other bad settings in SQL Server it has always been this way so Microsoft will not change it. Similar in nature to MAX DOP, COP, and other server settings that every good dba knows they need to change when standing up a new server.

Turning on ARITHABORT

Now that we have verified that the setting is OFF, and our .net connections are also using ARITHABORT OFF let’s turn it on at the server and try out PowerShell test again. To turn on the ARITHABORT setting  run this script:

/* SET ARITHABORT ON */
-- NOTE: By enabling this at the instance level all .net clients will automatically start connecting with using SET ARITHABORT ON
DECLARE @options TABLE ([name] nvarchar(35), [minimum] int, [maximum] int, [config_value] int, [run_value] int);
DECLARE @Value INT;
INSERT INTO @options ([name], [minimum], [maximum], [config_value], [run_value])
EXEC sp_configure 'user_options';
SELECT @Value = [config_value] | 64
FROM @options;
EXEC sp_configure 'user_options', @Value;
RECONFIGURE;
SELECT * FROM @options; -- prior state
EXEC sp_configure 'user_options'; -- current state
GO

Results:

SQL SERVER - Setting ARITHABORT ON for All Connecting .Net Applications ARITHABORT3

The top grid shows the old configured values, and the bottom the new values. So now we can run our PowerShell test again and we should get:

Setting
——-
ARITHABORT ON

So by changing the setting at the server level, our PowerShell, and .net connections are also now connecting with the recommended value of ARITHABORT ON automatically and without having to edit the applications!

Turning on ARITHABORT

So, how do we turn ARITHABORT back to OFF? If you really need to change it back for whatever reason you can use this script:

/* SET ARITHABORT OFF */
DECLARE @options TABLE ([name] nvarchar(35), [minimum] int, [maximum] int, [config_value] int, [run_value] int);
DECLARE @Value INT;
INSERT INTO @options ([name], [minimum], [maximum], [config_value], [run_value])
EXEC sp_configure 'user_options';
SELECT @Value = [config_value] & ~64
FROM @options;
EXEC sp_configure 'user_options', @Value;
RECONFIGURE;
SELECT * FROM @options; -- prior state
EXEC sp_configure 'user_options'; -- current state

NOTE: This has not been tested with all drivers so it may not affect other types of connections. I have tested .net connections, and PowerShell. I am curious to find out if other types of connections are positively affected.

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

First appeared on SQL SERVER – Setting ARITHABORT ON for All Connecting .Net Applications

SQL SERVER – FIX: Error 17836: Length Specified in Network Packet Payload Did Not Match Number of Bytes Read; the Connection has been Closed

$
0
0

SQL SERVER - FIX: Error 17836: Length Specified in Network Packet Payload Did Not Match Number of Bytes Read; the Connection has been Closed rj45 One of my clients reported that they are seeing below error in SQL Server ERRORLOG. He noticed a strange error of the network packet.

2018-08-06 07:09:41.363 Logon Error: 17836, Severity: 20, State: 17.
2018-08-06 07:09:41.363 Logon Length specified in network packet payload did not match number of bytes read; the connection has been closed. Please contact the vendor of the client library. [CLIENT: xx.xx.xx.xx]

Based on my understanding the error message means that there is some process trying to connect at SQL port but it’s not a valid SQL related activity.

WORKAROUND/SOLUTION

You can easily reproduce this error by doing Telnet on SQL Server IP and Port locally on the SQL Server machine. This also means that if SQL receives an invalid packet/data on the port where SQL is listening and then SQL would say –

Hey! This is not a login request or a query request and I don’t know how to process it. Let me report it to ERRORLOG.

Here are few more causes based on my search on the internet:

  1. Network team doing Port Scanning
  2. Sometimes Antivirus programs do check the port.
  3. MSSQL server is under a DDoS

You may want to look at the error message and check the IP of the machine and see what that is.

Have you encountered such messages in ERRORLOG? What was the cause which you found? If its very frequent error, then you may want to restrict that IP.

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

First appeared on SQL SERVER – FIX: Error 17836: Length Specified in Network Packet Payload Did Not Match Number of Bytes Read; the Connection has been Closed


SQL SERVER – Install Error – The Reporting Services Catalog Database File Exists. Select a Reporting Services files-only mode installation

$
0
0

SQL SERVER - Install Error - The Reporting Services Catalog Database File Exists. Select a Reporting Services files-only mode installation medical-history One of my clients was doing a remote installation of SQL Server via command prompt. During the testing phase, they encountered an error. In this blog, we would learn how to fix error The Reporting Services catalog database file exists.

When they contacted me, they already found my earlier blog on the same error.

SQL SERVER – FIX: Rule “Reporting Services Catalog Database File Existence” Failed

I asked them complete log to see the error and here it was.

Overall summary:
Final result: Failed: see details below
Exit code (Decimal): -2067921932
Exit facility code: 1214
Exit error code: 1012
Exit message: The Reporting Services catalog database file exists. Select a Reporting Services files-only mode installation.
Start time: 2018-08-08 13:20:46
End time: 2018-08-08 13:21:56
Requested action: Install

But they wanted to check if there is some other solution as they are doing the setup from command prompt remotely. This means that they would need to delete the file to proceed. This would increase their work as they need to parse the log to see the error, check if this is the error then delete those files which I mentioned in my earlier blog and then run the setup again. Rather than that, they wanted an easy way to “just deploy it without error”

WORKAROUND/SOLUTION

I tried explaining to them that this error would not be seen in new/fresh installation. The error would be seen if they have done a prior installation of SQL on the machine with Reporting Services. But they wanted to know the “easy” workaround.

Here is the command which they were using

cmd /c setup.exe /q /IAcceptSQLServerLicenseTerms /Action=Install /ConfigurationFile=”C:\SQLMedia\SQLInstall.ini”

I looked into the ini file which they were using and found a solution for them. The config file has no setting provided for RSINSTALLMODE. Due to this setup was taking DefaultNativeMode. Below is explained in Microsoft documentation

If the installation includes the SQL Server Database engine, the default RSINSTALLMODE is DefaultNativeMode.If the installation does not include the SQL Server Database engine, the default RSINSTALLMODE is FilesOnlyMode. If you choose DefaultNativeMode but the installation does not include the SQL Server Database engine, the installation automatically changes the RSINSTALLMODE to FilesOnlyMode

So, I asked them to add the following line in SQLInstall.ini file.

RSINSTALLMODE=FilesOnlyMode

Now, if I read the error message, it also tells me the same. After this, the setup deployment was going fine even if SSRS files were there. Have you faced a similar issue with SQL prompt installation via command prompt?

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

First appeared on SQL SERVER – Install Error – The Reporting Services Catalog Database File Exists. Select a Reporting Services files-only mode installation

SQL SERVER – WMI Error 0x80041017 – Invalid Query Using WBEMTest

$
0
0

During my free time, I do provide assistance to the community. Sometimes via forums, sometimes by giving a free session to local user group related to SQL Server. In this blog, I would share the steps to fox WMI error 0x80041017, Invalid Query.

In one of the forum posts, there was an issue related to WMI query. I asked to use WBEMTest utility to verify if WMI is working correctly on the server. Here were the steps I shared with him.

  1. From the Start menu, click Run, and then enter WBEMtest.
  2. The WBEMtest.exe dialog appears. Click Connect.
  3. In the first text field, type the WMI Provider for Computer Management namespace: root\cimv2. Click Connect.
  4. Click Query. Type a query that returns the current services running on the local computer:

Select * from Win32_Service.

  1. Click Apply.

When he performed this test, it gave an error:

Number: 0x80041017
Facility: WMI
Description: Invalid query

This means WMI for Windows is broken. I search and found below script which can help in fixing such error.

WORKAROUND/SOLUTION

Copy below script to notepad and save it as .bat extension. Then, run it from a command prompt with admin right (Run As Administrator)

@echo off
sc config winmgmt start= disabled
net stop winmgmt /y
%systemdrive%
cd %windir%\system32\wbem
for /f %%s in (‘dir /b *.dll’) do regsvr32 /s %%s
wmiprvse /regserver
sc config winmgmt start= auto
net start winmgmt
for /f %%s in (‘dir /s /b *.mof *.mfl’) do mofcomp %%s
cd c:\windows\system32
lodctr /R
cd c:\windows\sysWOW64
lodctr /R

Reboot the machine and test WMI. Following the outcome of the test

SQL SERVER - WMI Error 0x80041017 - Invalid Query Using WBEMTest wmi-invalid-query-01

Here is the output of the query after fixing the error

SQL SERVER - WMI Error 0x80041017 - Invalid Query Using WBEMTest wmi-invalid-query-02

Have you encountered such error? It took me a long time to find the right solution. Hopefully, this would help someone. Please comment if it helped you in fixing any WMI issue.

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

First appeared on SQL SERVER – WMI Error 0x80041017 – Invalid Query Using WBEMTest

SQL SERVER – Error: 17300 – The Error is Printed in Terse Mode Because There was Error During Formatting

$
0
0

SQL SERVER - Error: 17300 - The Error is Printed in Terse Mode Because There was Error During Formatting errorpony One of my clients contacted me in a situation where their business was down! Their production SQL Server instance used by their Human Resource team was unable to start in a clustered environment. In this blog, we would learn about how to fix the error: 17300 – The error is printed in terse mode because there was an error during formatting received during SQL startup. (To save my client privacy, I have changed the name and location)

As usual, during such situation, I always start with SQL Server ERRORLOG. SQL SERVER – Where is ERRORLOG? Various Ways to Find ERRORLOG Location

In ERRORLOG file, we get the following error message from when we try to start SQL service manually:

Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.

Based on my search on the internet, this error is due to insufficient memory available to SQL Server instance. So, the solution would be to increase SQL memory. But how? SQL is not stating at all!

SOLUTION/WORKAROUND

  1. Use the following command to start SQL Server instance HR and use SQLCMD to log in SQL:

net start MSSQLServer /mSQLCMD /f

Note: /f or -f: this parameter is used to start SQL Server in “minimal configuration” mode. This parameter is used in situations when a DBA has changed some configuration options which is causing SQL Server service startup failure. This startup parameter might be the only way to correct the mistakes in the SQL Server configuration. I was thinking to use “m” as “minimal” but its already taken by single user mode.

  1. Use the following command to log in SQL server:

SQLCMD -E -S SQLPINAL

  1. Reset the max server memory for SQL instance
EXEC sp_configure 'show advanced option', '1'
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'max server memory', '102400' 
GO
RECONFIGURE WITH OVERRIDE
GO

Note: you need to set the value based on your requirement. I have used 10 GB for my environment.

In their environment, I found that max server memory was set to 128 MB and no one could figure out how it happened. Do you know any method? Please comment and let me know.

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

First appeared on SQL SERVER – Error: 17300 – The Error is Printed in Terse Mode Because There was Error During Formatting

SQL SERVER – Useful Queries – Why Huge Transaction Log (LDF) File? Fix Low Disk Free Space on the Drive Used by LDF Files

$
0
0

During my Comprehensive Database Performance Health Check engagement with the client, one of the most common issue found was the huge size of the transaction log file. In this blog, we would learn about useful queries which I use to help my client in fixing Huge Transaction Log (LDF) File.

SQL SERVER - Useful Queries - Why Huge Transaction Log (LDF) File? Fix Low Disk Free Space on the Drive Used by LDF Files hugetlog

Here are the three most common queries which I use when I am trying to fix an issue where LDF file is huge as compared to MDF file.

  1. DBCC SQLPERF(LOGSPACE)
  2. select name, recovery_model_desc, log_reuse_wait,log_reuse_wait_desc from sys.databases
  3. DBCC LOGINFO

Let’s understand each query and its usage.

DBCC SQLPERF(LOGSPACE)

As per books online – it returns the current size of the transaction log and the percentage of log space used for each database. Use this information to monitor the amount of space used in a transaction log.

SYS.DATABASES

We can use below query to find the recovery model of each database and find the cause of not able to truncate the log file (log_reuse_wait_desc) column.

SELECT name
	,recovery_model_desc
	,log_reuse_wait
	,log_reuse_wait_desc
FROM sys.databases

DBCC LOGINFO

Returns virtual log file (VLF) information of the transaction log. Note all transaction log files are combined in the table output. Each row in the output represents a VLF in the t-log and provides information relevant to that VLF in the log.

Above is taken from the documentation of dm_db_log_info. Here is the query we should use after SQL 2016.

SELECT * FROM sys.dm_db_log_info(db_id())

Else we can use DBCC LOGINFO

Using the above three, I get an understanding of cause and possible solution to get free space.

WORKAROUND/SOLUTION

Here is the query which you can copy paste when I get engaged with you or you are trying to fix the space issue. (Change the Database Name)

USE Database_Name_Here
GO
DBCC SQLPERF(LOGSPACE)
GO
DBCC LOGINFO
GO
select * from sys.dm_db_log_info(db_id()) 
GO
select name
	,recovery_model_desc
	,log_reuse_wait
	,log_reuse_wait_desc
 from sys.databases where database_id = db_id()

Please let me know if the above queries are useful to find out why transaction log is huge.

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

First appeared on SQL SERVER – Useful Queries – Why Huge Transaction Log (LDF) File? Fix Low Disk Free Space on the Drive Used by LDF Files

SQL SERVER – Unable to Remove Replication Publication – Could not Delete the Subscription at Subscriber ‘SubServer’ in Database ‘SubDB’

$
0
0

SQL SERVER - Unable to Remove Replication Publication - Could not Delete the Subscription at Subscriber 'SubServer' in Database 'SubDB' replication While playing with my lab server having broken replication, I encountered an error message when I was trying to remove publication. In this blog, we would learn about how to fix error Could not delete the subscription at Subscriber ‘SubServer’ in database ‘SubDB’.

Basically, I was not able to remove Publication ‘PubName’ and it reported the below error message:

Could not delete the subscription at Subscriber ‘SubServer’ in database ‘SubDB’.
Invalid object name ‘dbo.syspublications’. (Microsoft SQL Server, Error:208)

WORKAROUND/SOLUTION

Based on my research, the error should not come if replication objects were cleaned up correctly. This means that in my environment there must be some orphaned replication objects, or some other commands blocked the previous command. I ran below command and it was successful.

EXEC sp_removedbreplication 'PubDB'

Here the documentation of sp_removedbreplication

This stored procedure removes all replication objects on the publication database on the Publisher instance of SQL Server or on the subscription database on the Subscriber instance of SQL Server. Execute in the appropriate database, or if the execution is in the context of another database on the same instance, specify the database where the replication objects should be removed. (ref)

Hope this would help someone who is having basic knowledge of SQL Replication and became accidental DBA.

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

First appeared on SQL SERVER – Unable to Remove Replication Publication – Could not Delete the Subscription at Subscriber ‘SubServer’ in Database ‘SubDB’

Viewing all 594 articles
Browse latest View live