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

SQL SERVER – How to Change Authentication Mode Using T-SQL Query

$
0
0

One of my clients asked an interesting question. It took a while for me to figure out the answer so sharing with my blog readers. In this blog, we would learn how to change authentication mode of SQL Server using T-SQL query instead of SQL Server Management Studio.

THE EMAIL WITH SITUATION

Hi Pinal,

I am an independent vendor of a software which uses SQL Express. I install SQL Server Express on client’s environment as a part of my software deployment. I realized that during installation I missed changing authentication mode to mixed mode and it installs SQL with Windows Authentication mode.

The challenge now is that the software is already shipped with this bug and I need to fix it quickly. There are few downloads so far, so I need to contact my clients and supply a fix. I know how to install SQL with mixed mode authentication, so I have already fixed it for further installations. I cannot ask my client to install SSMS on the machines to change the mode and then uninstall it.

Do you have any solution for me? I am not well-versed with SQL so there might be an easy answer, but I just do not have time to search on the internet. You can imagine the pressure to get the fix released for already downloads.

Awaiting reply!

WORKAROUND/SOLUTION

As you can see in the above email, he wanted quick help. So, I made an offer, he accepted, and we started working. He told that he knows that below is what needs to be done and restart SQL.

SQL SERVER - How to Change Authentication Mode Using T-SQL Query mixed-auth-tsql-01

Here is the error we would see in ERROLROG when we try to use SQL account to log in and SQL is configured with “Windows Authentication mode”.

Error: 18456, Severity: 14, State: 58.
Login failed for user ‘AppLogin’. Reason: An attempt to login using SQL authentication failed. The server is configured for Windows authentication only. [CLIENT: <local machine>]

Here is the T-SQL to do the same.

  1. To set mode to “Windows Authentication” (LoginMode= 1)
USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', 
N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 1
GO
  1. To set mode to “SQL Server and Windows Authentication mode” (LoginMode= 2)
USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', 
N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 2
GO

I must tell you that my client was smart. He wrote a batch file to change the registry key for the instance which software installed and to restart the SQL Service for that instance. After this software also started working and we both were happy.

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

First appeared on SQL SERVER – How to Change Authentication Mode Using T-SQL Query


SQL SERVER – Azure Key Vault Deletion Error – Vault ‘ProdRecoveryVault’ Cannot be Deleted as There are Existing Resources Within the Vault

$
0
0

SQL SERVER - Azure Key Vault Deletion Error - Vault 'ProdRecoveryVault' Cannot be Deleted as There are Existing Resources Within the Vault warning Along with my performance consulting, I also help many clients in fixing some quick issue. You can refer to various consulting services which I provide. This blog is an outcome of one such engagement where the has Azure Key vault and was not able to delete it. In this blog, we would learn about how to fix error Vault ‘Name’ cannot be deleted as there are existing resources within the vault.

Here is the complete error in the Azure portal.

Vault deletion error

Vault ‘ProdRecoveryVault’ cannot be deleted as there are existing resources within the vault. Please delete any replicated items, registered servers, Hyper-V sites (Used for Site Recovery). policy associations for System Center VMM clouds (Used for Site Recovery) and then delete the vault.

THE SOLUTION

While looking at key vault I found that it was not empty. Long-term protection data from Azure SQL databases which caused this error. I found below useful PowerShell script that will delete the content of the vault and then will delete the vault itself.

Login-AzureRmAccount
$ResourceGroupName = "Default-SQL-SouthIndia"             
$RecoveryServiceVaultName = "ProdRecoveryVault"                     
$Vault = Get-AzureRmRecoveryServicesVault -ResourceGroupName $ResourceGroupName -Name $RecoveryServiceVaultName
Set-AzureRmRecoveryServicesVaultContext -Vault $Vault
$Container = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureSQL -FriendlyName $Vault.Name 
$Item = Get-AzureRmRecoveryServicesBackupItem -Container $Container -WorkloadType AzureSQLDatabase 
$Vault = Get-AzureRmRecoveryServicesVault -ResourceGroupName $ResourceGroupName -Name $RecoveryServiceVaultName 
Set-AzureRmRecoveryServicesVaultContext -Vault $Vault
$Containers = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureSQL -FriendlyName $Vault.Name 
ForEach ($Container in $Containers) 
{
   $Items = Get-AzureRmRecoveryServicesBackupItem -container $Container -WorkloadType AzureSQLDatabase
   ForEach ($Item in $Items)
   {
      # Remove the backups from the vault
     Disable-AzureRmRecoveryServicesBackupProtection -item $Item -RemoveRecoveryPoints -ea SilentlyContinue
   }
   Unregister-AzureRmRecoveryServicesBackupContainer -Container $Container
}
Remove-AzureRmRecoveryServicesVault -Vault $Vault

After running above, we saw that vault got removed successfully. This was very interesting to me. Have you ever faced such a problem, if yes, how did you resolve the error?

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

First appeared on SQL SERVER – Azure Key Vault Deletion Error – Vault ‘ProdRecoveryVault’ Cannot be Deleted as There are Existing Resources Within the Vault

SQL SERVER – Always On Secondary Replica Huge Redo Queue – Version Store is Full. New Version(s) Could Not be Added

$
0
0

SQL SERVER - Always On Secondary Replica Huge Redo Queue – Version Store is Full. New Version(s) Could Not be Added documents One of my earlier clients to whom I helped in configuration Always On Availability Group came back to me with strange behavior. In this blog, we would discuss error Version store is full. New version(s) could not be added. In this situation, I also found that the redo queue was increasing continuously on the secondary replica.

THE SITUATION

My client has set up three nodes availability group with one primary, one synchronous secondary and one asynchronous secondary. They noticed that redo queue size was increasing continuously on secondary replica (both of them, sync and async)

I started digging using DMV and found that redo process was working but it was waiting for the LATCH on APPEND_ONLY_STORAGE_FIRST_ALLOC. Here is the query used

SELECT * FROM sys.sysprocesses WHERE dbid = db_id('ProdDB)

Then I looked into SQL Server ERRORLOG and found below message logged continuously

The version store is full. New version(s) could not be added. A transaction that needs to access the version store may be rolled back. Please refer to BOL on how to configure tempdb for versioning.

Based on my understanding of secondary version store, it would come into picture when secondary is readable. All queries that run against the secondary databases are automatically mapped to snapshot isolation transaction level, even when other transaction isolation levels are explicitly set.

Active Secondaries: Readable Secondary Replicas (Always On Availability Groups)

WORKAROUND/ SOLUTION

I found that they have a serious space issue on the drive where TempDB is located. The TempDB was not able to grow and hence new versions were not getting generated.

Due to readable secondary, SQL was using version store so the quick solution, in this case, was to disable read from secondary replicas. We used below command to disallow reads from secondary.

USE [master]
GO
ALTER AVAILABILITY GROUP [PROD_AG]
MODIFY REPLICA ON N'Godzilla_2' WITH (SECONDARY_ROLE (ALLOW_CONNECTIONS = NO))
GO

We did this for both replicas. As soon as we disabled the reads, version store vanished, and redo picked up the speed. Now since TempDB was not in use, we were able to shrink it as well to avoid space issues on the drive which was having TempDB database.

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

First appeared on SQL SERVER – Always On Secondary Replica Huge Redo Queue – Version Store is Full. New Version(s) Could Not be Added

SQL SERVER – Unable to Create Always On Listener – Attempt to Locate a Writeable Domain Controller (in Domain Unspecified Domain) Failed

$
0
0

SQL SERVER – Unable to Create Always On Listener - Attempt to Locate a Writeable Domain Controller (in Domain Unspecified Domain) Failed xerror This is one of the common causes in Always On for which my clients contact me – “Unable to create listener”. In this blog we would learn about how to fix event Id 1212 – Attempt to locate a writeable domain controller.

When my client contacted me, they were having the same error with three different clusters which makes them believe that this an issue outside the cluster configuration. They were unable to Create Listener and getting Msg 41009 – The Windows Server Failover Clustering (WSFC) Resource Control API Returned Error.

First thing I did was to check the event log and I found below message.

Log Name: System
Source: Microsoft-Windows-FailoverClustering
Event ID: 1212
Task Category: Network Name Resource
Level: Error
Keywords:
User: SYSTEM
Description:
Cluster network name resource ‘AGListener’ cannot be brought online. Attempt to locate a writeable domain controller (in domain unspecified domain) in order to create or update a computer object associated with the resource failed for the following reason:
More data is available.
The error code was ‘234’. Ensure that a writeable domain controller is accessible to this node within the configured domain. Also, ensure that the DNS server is running in order to resolve the name of the domain controller.

I explained that whenever there are any issues related to cluster resource, we should always look at cluster log. If you are not sure how to generate cluster logs, read my earlier blog on the same topic. SQL SERVER – Steps to Generate Windows Cluster Log?

Here were the messages in the cluster log

ERR[RES] Network Name: [NNLIB] Searching for object SQLLISTENER on first choice DC failed. Error 234.
WARN [RES] Network Name : AccountAD: PopulateNetnameADState – FindSuitableDCNew failed with error 234 with known good password. Retrying with proposed password
INFO [RES] Network Name: [NNLIB] FindSuitableDCNew – objectName SQLLISTENER, username – MZNAPWCLEQU004$, firstChoiceDCName – \\DCAZ.domain.com
INFO [RES] Network Name: [NNLIB] LDAP bind to first choice DC \\DCAZ.domain.com failed. Error 5. Trying to LDAP bind with empty DC
INFO [RES] Network Name: [NNLIB] LDAP bind to first choice DC failed. Error 5. Trying second choice DC
INFO [RES] Network Name: [NNLIB] LDAP bind to second choice DC failed. Error 5.
ERR [RES] Network Name : AccountAD: PopulateNetnameADState – FindSuitableDCNew failed with error 5 with known proposed password
ERR [RES] Network Name : AccountAD: Populate netname AD state (bind to DC & search for object if exists) for object SQLLISTENER failed with error 234

We are seeing two errors here:

  1. Error 234
  2. Error 5

I don’t know what error 234 is but I do know that error 5 = Access is denied.

One of the most common cause would be where the Domain Administrator does not allow the CNO “Read All Properties” and “Create Computer Objects” permissions. You might see “Access is denied” in the event log.

Here are the steps, which are also known as pre-staging of virtual computer object (VCO) in domain controller.

  • If possible, connect to the domain controller. Ensure that we are logged in as a user that has permissions to create computer objects in the domain.
  • Open the Active Directory Users and Computers Snap-in (dsa.msc).
  • In Menu > View -> Advanced Features. (Otherwise, we would not see option explained in next steps)
  • Right-click the OU/Container where we want the VCO to be created and click “New” -> “Computer”
  • Provide a name for the object (This will be your SQL Server Network Name in FCI or Listener Name in AG) and click “OK”:
  • Right-click on the on the VCO which we just created and select “Properties”. Click the security tab and then click “Add”:
  • Enter the CNO (Make sure to select “Computers” option in the “Object Types” window) and click “OK”. The CNO is a Cluster Name Object. This is the name of the Windows Cluster name NOT listener or FCI name.
  • Give CNO “Full Control” over the VCO.

If all above steps are followed, we should not get access denied and if we try creating Listener, it should be successful.

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

First appeared on SQL SERVER – Unable to Create Always On Listener – Attempt to Locate a Writeable Domain Controller (in Domain Unspecified Domain) Failed

SQL SERVER – Always On Availability Groups and Full-Text Index

$
0
0

SQL SERVER - Always On Availability Groups and Full-Text Index alwaysonfulltext One of the most successful offerings from me has been Comprehensive Database Performance Health Check. Sometimes during my assistance, some random issues appear which I try to solve as well. In a recent engagement, one of their developers asked a question about the coexistence of full-text index and always on availability groups. In this blog, we would learn about one common issue which you might face when full text and availability group is used together.

THE PROBLEM

One of my clients to whom I helped in configuring Always On Availability Groups came back to me with an interesting situation. They have observed blocking of reading queries on the secondary replica. Since the database is in read-only mode, they wanted to know how write is being performed in the database which is causing blocking?

THE INVESTIGATION

I knew that this is not a user write activity but must be a system write activity which is causing blocking. When I started troubleshooting, I found below.

  1. DB STARTUP thread (redo thread) being blocked by user session in sys.dm_exec_requests
  2. Wait type: LCK_M_SCH_M
  3. Wait_resource: METADATA: database_id = 8 COMPRESSED_FRAGMENT(object_id = 484196875, fragment_id = 9715700) – found using sys.all_objects

When I looked further, I found the object name was ifts_comp_fragment_484196875_10739738 and it was an INTERNAL_TABLE.

THE SOLUTION

It became clear that the redo thread was getting blocked not a user session. This causes the replica to start lagging because redo stops often. In my lab, I also observed that if a database with a full-text index is in an availability group, we can see the same type of blocking whenever the full text is index is enabled for automatic or manual population, and if there are read queries running full-text searches.

For my client, we were able to prevent this behavior by disabling change tracking. My client was OK with disabling change tracking on the full-text index temporarily and then setting up an incremental population on a schedule. Here is the T-SQL to change the tracking to manual.

USE [CRM]
GO
ALTER FULLTEXT INDEX ON [dbo].[CustomerData] SET CHANGE_TRACKING = MANUAL
GO

Later I suggested my client to refer Populate Full-Text Indexes and think about “Incremental population based on a timestamp”. This was a long-term solution for them.

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

First appeared on SQL SERVER – Always On Availability Groups and Full-Text Index

SQL SERVER – Reporting Services Not Starting After Maintenance Window

$
0
0

SQL SERVER - Reporting Services Not Starting After Maintenance Window errorspy This is the issue faced on my test server and I found something interesting. In this blog, we would learn about one of the reasons why SQL Server Reporting Services (SSRS) couldn’t start after regular maintenance.

I stopped SQL related services without any issue during the maintenance window (let’s call it as a fake maintenance as it as my lab server). Now, while restarting the same all the SQL related servers got started except SSRS service. After restart server, it started.

I checked on the internet to find a way to find the cause. I started checking the SSRS error log file Reporting Services Log Files and Sources

Here is the information I could see.

  1. servicecontroller!WindowsService_0!f80!10/22/2018-06:14:04:: e ERROR: Error initializing configuration from the database: Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException: The report server cannot open a connection to the report server database. A connection to the database is required for all requests and processing. —> System.Data.SqlClient.SqlException: Cannot open database “ReportServer” requested by the login. The login failed.Login failed for user ‘sa’.
  1. resourceutilities!WindowsService_0!f80!10/22/2018-06:14:05:: i INFO: Reporting Services starting SKU: Enterprise
  2. library!WindowsService_0!fd0!10/22/2018-06:14:05:: e ERROR: Throwing Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException: , Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException: The report server cannot open a connection to the report server database. A connection to the database is required for all requests and processing. —> System.Data.SqlClient.SqlException: Cannot open database “ReportServer” requested by the login. The login failed.Login failed for user ‘sa’.
  1. library!WindowsService_0!fd0!10/22/2018-06:14:05:: e ERROR: ServiceStartThread: Exception caught while starting service. Error: Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException: The report server cannot open a connection to the report server database. A connection to the database is required for all requests and processing. —> System.Data.SqlClient.SqlException: Cannot open database “ReportServer” requested by the login. The login failed. Login failed for user ‘sa’.
  1. library!WindowsService_0!fd0!10/22/2018-06:14:05:: e ERROR: ServiceStartThread: Attempting to start service again…
  2. library!WindowsService_1!ff4!10/22/2018-06:14:55:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.ReportServerStorageException: , An error occurred within the report server database. This may be due to a connection failure, timeout or low disk condition within the database.;
  3. library!WindowsService_1!fa0!10/22/2018-06:14:55:: w WARN: Transaction rollback was not executed connection is invalid
  4. library!WindowsService_1!17ac!10/22/2018-06:15:52:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.ReportServerStorageException:, An error occurred within the report server database. This may be due to a connection failure, timeout or low disk condition within the database.;
  5. schedule!WindowsService_1!17ac!10/22/2018-06:15:52:: Unhandled exception caught in Scheduling maintenance thread: Microsoft.ReportingServices.Diagnostics.Utilities.ReportServerStorageException: An error occurred within the report server database. This may be due to a connection failure, timeout or low disk condition within the database. —> System.Data.SqlClient.SqlException: Database ‘msdb’ is being recovered. Waiting until recovery is finished.

Note that there were no numbers in the log. I have added them to provide more explanation.

WORKAROUND/SOLUTION

If we look at each numbered item, it has some messages. Let me put them below with the interesting piece.

  1. e ERROR: Error initializing configuration from the database: Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException: The report server cannot open a connection to the report server database. A connection to the database is required for all requests and processing. —> System.Data.SqlClient.SqlException: Cannot open database “ReportServer” requested by the login. The login failed. Login failed for user ‘sa’.
  1. i INFO: Reporting Services starting SKU: Enterprise
  2. e ERROR: Throwing Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException: , Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException: The report server cannot open a connection to the report server database. A connection to the database is required for all requests and processing. —> System.Data.SqlClient.SqlException: Cannot open database “ReportServer” requested by the login. The login failed. Login failed for user ‘sa’.
  1. e ERROR: The report server cannot open a connection to the report server database. A connection to the database is required for all requests and processing. —> System.Data.SqlClient.SqlException: Cannot open database “ReportServer” requested by the login. The login failed. Login failed for user ‘sa’.
  1. e ERROR:Attempting to start service again…
  2. e ERROR: An error occurred within the report server database. This may be due to a connection failure, timeout or low disk condition within the database.;
  3. w WARN: Transaction rollback was not executed connection is invalid
  4. e ERROR: An error occurred within the report server database. This may be due to a connection failure, timeout or low disk condition within the database.;
  5. e ERROR: An error occurred within the report server database. This may be due to a connection failure, timeout or low disk condition within the database. —> System.Data.SqlClient.SqlException: Database ‘msdb’ is being recovered. Waiting until recovery is finished.

There are three kinds of tags we can see above, i-INFO, e-ERROR, and w-WARN. If you read them again, it would start making sense. As we can see that there may be a connection failure, timeout or low disk condition within the report server database.  Also, the system database ‘msdb’ was being recovered and its recovery was not finished. Due to this SSRS service did not start immediately.

When I checked SQL ERRORLOG, I found that MSDB database recovery has taken time to come online and hence SSRS was not able to connect to it. Now, this explained everything and it was a nice experience to do “detective” work to find the root cause.

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

First appeared on SQL SERVER – Reporting Services Not Starting After Maintenance Window

SQL SERVER – XML Document Could Not be Created Because Server Memory is Low. Use sp_xml_removedocument to release XML documents

$
0
0

SQL SERVER - XML Document Could Not be Created Because Server Memory is Low. Use sp_xml_removedocument to release XML documents xml Most of my earnings come from my role as SQL Server Performance Tuning and Optimization consultant. Every single day I work with few customers so that I can maintain the quality of my work with each of them. As you can imagine, I face new challenges and learn new ways to tune SQL Server. In this blog post, we will discuss an error XML document could not be created because server memory is low. Use sp_xml_removedocument to release XML documents.

System.Web.HttpUnhandledException (0x80004005): Exception of type ‘System.Web.HttpUnhandledException’ was thrown. —> HRMS.Runtime.Remoting.RemoteServerException: The remote server generated an exception.
<Error>
<Description>XML document could not be created because server memory is low. Use sp_xml_removedocument to release XML documents.</Description>
</Error>    

Above message is error number 6624 in SQL Server.

Now here is the interesting part, a server had around 300 GB of RAM and most of it was free when SQL raised the error. It looks like there is some memory limit somewhere. My further search on the internet shows: “A parsed document is stored in the internal cache of SQL Server. The MSXML parser (Msxmlsql.dll) uses one-eighth the total memory available for SQL Server.” When I looked further, I also found that it can’t take more than 4 GB of RAM irrespective of total RAM on the server.

WORKAROUND/SOLUTION

When we looked at the pattern of the issue, it was clear that they are having an increase in the data getting processed. OpenXML is not able to scale because with the data processing. It worked fine when data was less but now it is hitting 4 GB limit and that’s why we are getting out of memory error, even though the message says “server” memory.

As a long terms solution, I helped them in changing the code to XQuery methods (value, query, nodes) for XML processing instead of OpenXML. As per documentation, XQuery uses different parser then OpenXml, and have much better memory management since it’s implemented in the engine itself. XQuery Language Reference (SQL Server)

So if you need to choose between OpenQuery and XQuery, then go with XQuery for scalability reasons.

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

First appeared on SQL SERVER – XML Document Could Not be Created Because Server Memory is Low. Use sp_xml_removedocument to release XML documents

SQL SERVER – Unable to Start Service SQLSERVERAGENT on Server (mscorlib)

$
0
0

There are several reasons for the error mentioned in the blog title. In this blog, we would learn about one of the causes of error Unable to start service SQLSERVERAGENT on a server.

When my client contacted me, they were in process of changing the hardware/drives and the path of SQL Server related files. After making changes to the path of SQLAgent.OUT file, they were unable to start SQL Server Agent Service. Here is the screenshot when they tried starting SQL Server Agent service via SQL Server Management Studio.

SQL SERVER - Unable to Start Service SQLSERVERAGENT on Server (mscorlib) sqlagt-stop-01

Here is the text of the above error message.

Unable to start service SQLSERVERAGENT on server ABCLProdSQLServer. (mscorlib)

When I joined the call with them, I checked the event log, I found below message.

Failed to initialize SQL Agent log (reason: Access is denied).

From above, we can say that SQL Server Agent is trying to write to a log file but unable to do so. Now, we needed to find out the location and file name. Below is the T-SQL code to get the location.

USE [msdb]
GO
EXEC sp_configure 'Agent XPs', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC msdb.dbo.sp_get_sqlagent_properties -- CHECK FOR errorlog_file column

Check for an errorlog_file column. When I checked the value for my client, it was

H:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Log

Above file was not getting generated due to an error in event log. Wait a second. Look closely, looks like my client missed SQLAgent.OUT file name over there. We already have a FOLDER called LOG and that’s why we can’t take a file with the same name.

WORKAROUND/SOLUTION

Now, since we have found that this was due to an incorrect value set for the SQL Server Agent log file, we need to correct the value. There are multiple ways to do it.

  1. Use below T-SQL
USE [msdb]
GO
EXEC sp_configure 'Agent XPs', 1
GO
EXEC msdb.dbo.sp_set_sqlagent_properties @errorlog_file=N'H:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Log\SQLAgent.out'
GO
  1. We can also modify the registry directly using “Start > Run > Regedit” and navigating to the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQLSERVER\SQLServerAgent

Highlighted piece is the combination of the SQL version and instance name. MSSQL13 stands for SQL Server 2016. MSSQL12 is for SQL Server 2014 and so on and so forth.

We need to change a value for “ErrorLogFile” and provide a valid file name.

Once we made above changes, SQL Server Agent got started without any further error.

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

First appeared on SQL SERVER – Unable to Start Service SQLSERVERAGENT on Server (mscorlib)


SQL SERVER – Script level upgrade for database ‘master’ failed because upgrade step msdb110_upgrade.sql encountered error 926, state 1, severity 25

$
0
0

SQL SERVER - Script level upgrade for database 'master' failed because upgrade step msdb110_upgrade.sql encountered error 926, state 1, severity 25 warning-1 I have helped many clients in upgrade failures via my On-Demand consulting and I am amazed to see various ways which can break SQL Server upgrade. In this blog we would learn about fixing error Script level upgrade for database ‘master’ failed because of upgrade step sqlagent100_msdb_upgrade.sql

Below are few earlier blogs which have other causes of same error:

SQL SERVER – Script level upgrade for database ‘master’ failed because upgrade step ‘sqlagent100_msdb_upgrade.sql’

SQL SERVER – Script level upgrade for database ‘master’ failed – There is already an object named ‘DatabaseMailUserRole’ in the database

SQL SERVER – Script level upgrade for database master failed – Error: 4860, Severity: 16, State: 1 – Cannot bulk load. SqlTraceCollect.dtsx does not exist

SQL SERVER – Error 15559 – Error 912 – Script Level Upgrade for Database ‘master’ Failed

SQL SERVER – Script Level Upgrade for Database ‘master’ Failed Because Upgrade Step ‘sqlagent100_msdb_upgrade.sql’ – Error: 5041: MODIFY FILE Failed

As I mentioned in an earlier blog, we need to look at the exact error in ERRORLOG. In my client’s case, here is what I saw in ERRORLOG.

  1. Error: 8355, Severity: 16, State: 1.
  2. Server-level event notifications cannot be delivered. Either Service Broker is disabled in msdb, or msdb failed to start. Event notifications in other databases could be affected as well. Bring msdb online, or enable Service Broker.
  3. Error: 926, Severity: 14, State: 1.
  4. Database ‘msdb’ cannot be opened. It has been marked SUSPECT by recovery. See the SQL Server errorlog for more information.
  5. Error: 912, Severity: 21, State: 2.
  6. Script level upgrade for database ‘master’ failed because upgrade step ‘msdb110_upgrade.sql’ encountered error 926, state 1, severity 25. 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.
  7. Error: 3417, Severity: 21, State: 3.
  8. 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.
  9. SQL Server shutdown has been initiated
  10. SQL Trace was stopped due to server shutdown. Trace ID = ‘1’. This is an informational message only; no user action is required.

I have put line number for clarity. Message in line number 7 onwards are scary and don’t trust/follow them. Upgrade failure is in line number 5 and 6. If you read complete message in line number 6, it tells error 926 encountered. Now, line number 3 is error number 926 which means database msdb can’t be opened.

WORKAROUND/SOLUTION

As mentioned in all earlier articles, we need to start SQL Service with trace flag 902 to bypass upgrade script and fix the cause of upgrade script failures. So, here are the steps I have done.

As I mentioned earlier, first we started SQL with trace flag 902. I started SQL using trace flag 902 as below via command prompt.

NET START MSSQLSERVER /T902

For named instance, we need to use below (replace instance name based on your environment)

NET START MSSQL$INSTANCENAME /T902

Refer: SQL SERVER – 2005 – Start Stop Restart SQL Server from Command Prompt

As soon as SQL was started, we were able to connect because upgrade didn’t run. Now, we need to fix issue i.e. fix the reason of MSDB suspect database. In my client’s situation, we restore to last known good backup of MSDB database. Once restore was completed, we stopped SQL Service and started normally (without any trace flag). This time upgrade scripts ran fine, and SQL was up and running.

Have you faced any other upgrade script failures? I would be happy to write a blog, if not written already, with due credit.

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

First appeared on SQL SERVER – Script level upgrade for database ‘master’ failed because upgrade step msdb110_upgrade.sql encountered error 926, state 1, severity 25

SQL SERVER – AlwaysOn – Queries Waiting for HADR_AR_CRITICAL_SECTION_ENTRY

$
0
0

In the past few days, I am being contacted by clients for AlwaysOn related issue. I have been writing a blog about them. In this blog, we would learn about how to fix wait for HADR_AR_CRITICAL_SECTION_ENTRY.

SQL SERVER - AlwaysOn - Queries Waiting for HADR_AR_CRITICAL_SECTION_ENTRY alwaysonerror

THE SITUATION

My client was using SQL Server in a virtual environment. Due to some instability with their network infrastructure, windows cluster lost quorum for few minutes and then it came back. As you might know that AlwaysOn availability group is tightly coupled with windows server failover cluster, so anything happening in the cluster could also impact AlwaysOn availability group. That is what precisely has happened here.

As usual, they sent me an email, I responded back with GoToMeeting details and we were talking to each other in a few minutes. When I joined the call with them:

  1. All of our AG modification queries (removing availability database, removing availability replica) were stuck waiting on HADR_AR_CRITICAL_SECTION_ENTRY.
  2. We were unable to make modifications to the AG as it was in an inconsistent state, pending updating the state of the replica.
  3. As per the Microsoft docs – Occurs when an Always On DDL statement or Windows Server Failover Clustering command is waiting for exclusive read/write access to the runtime state of the local replica of the associated availability group.

SOLUTION/WORKAROUND

Based on my search on the internet, restart of SQL instance is the only way to come out of this.

We set the AG failover to manual and restarted both replicas; after doing so, our secondary replica became synchronized after a few minutes and we were able to successfully remove databases from the AG. We tested failover back and forth, and everything was working as expected.’

Have you seen this wait in your environment? It would be great if you can share the cause of that via comments and how did you come out of it.

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

First appeared on SQL SERVER – AlwaysOn – Queries Waiting for HADR_AR_CRITICAL_SECTION_ENTRY

SQL SERVER – Initializing the FallBack Certificate Failed With Error Code: 1, State: 20, Error Number: 0

$
0
0

One of my clients came with an issue with SQL Server startup. As per them, they just changed the password of SQL Server Service account using the configuration manager. In this blog we would learn about how to fix Initializing the FallBack certificate failed with error code: 1, state: 20, error number: 0 during SQL startup.

THE INVESTIGATION

As I mentioned earlier, my client informed that they have changed the service account password. As usual, I first asked to check SQL ERRORLOG to know the exact message. SQL SERVER – Where is ERRORLOG? Various Ways to Find ERRORLOG Location

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

  1. Error: 17190, Severity: 16, State: 1.
  2. Initializing the FallBack certificate failed with error code: 1, state: 20, error number: 0.
  3. Unable to initialize SSL encryption because a valid certificate could not be found, and it is not possible to create a self-signed certificate.
  4. Error: 17182, Severity: 16, State: 1.
  5. TDSSNIClient initialization failed with error 0x80092004, status code 0x80. Reason: Unable to initialize SSL support. Cannot find object or property.
  6. Error: 17182, Severity: 16, State: 1.
  7. TDSSNIClient initialization failed with error 0x80092004, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. Cannot find object or property.
  8. Error: 17826, Severity: 18, State: 3.
  9. 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.

Note that I have added line number for clarity. The service account was a domain account.

I search on the internet and found many blogs having a wealth of information based on the error message. It looks like SQL Server generates a self-signed certificate by default for encryption. When I searched for 0x80092004 I could find below on Microsoft site.

The value 0x80092004 is an SSPI error code that translates to CRYPT_E_NOT_FOUND. This error was generated by SSL because it could not locate the certificate. Here are the possible causes

  1. SQL Server Startup account (service account) does not have permission or does not have a local profile in the system.
  2. The SQL server startup account cannot access a pre-existing key container needed to create the self-signed certificate.

I captured Process Monitor to see which key is getting accessed. I saw that below key is getting accessed.

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

Using PSGETSID I found SID and found that there was a key named SID.bak. Even if I rename and remove .bak, it was coming back when I try to restart. I could also see TEMP folder getting create in C:\USERS\ folder and getting deleted automatically.

SOLUTION/WORKAROUND

Above test confirmed that this was an issue due to Temporary profile getting loaded for SQL Service account. I tool back up and delete the key SID.bak. Please make sure you delete the key belonging to SID of service account only. Here is the screenshot to make sure you are at the right key

SQL SERVER - Initializing the FallBack Certificate Failed With Error Code: 1, State: 20, Error Number: 0 pro-corr-01

Hopefully, this would help you in fixing the SQL Server startup issue.

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

First appeared on SQL SERVER – Initializing the FallBack Certificate Failed With Error Code: 1, State: 20, Error Number: 0

SQL SERVER – Steps to Change IP Address of SQL Server Failover Cluster Instance

$
0
0

SQL SERVER - Steps to Change IP Address of SQL Server Failover Cluster Instance warning-1 There have been many questions in my mailbox asking about exact steps to change the windows cluster and SQL failover cluster IP address to the new VLAN. In this blog, I would outline the steps which are needed to perform this migration.

If we look at the IP addresses in a SQL Cluster running on Windows Cluster, we can see about below IPs

  • Cluster nodes IP addresses.
  • SQL IP address in Cluster (also called as SQL Virtual IP)
  • Cluster Access Point IP address (also called Cluster IP)

SOLUTION/WORKAROUND

  1. To change the cluster nodes IP addresses below are the steps:
  • Present new adapters with the new IP addresses
  • Confirm that new network presented in the “Cluster network”. Make sure there are two connections from all cluster nodes. Also make sure that they are online.
  • Make sure that this network is marked for use to cluster and heartbeat as well.
  1. To change the SQL IP address:
  • Choose IP address resource, for which we need to change the IP, right click and go to properties, change the subnet to the new subnet and then enter the new IP address.
  • Change the dependency, if needed. (If you created a new IP resource rather than modifying it)
  • Make sure that the new IP address resource is coming online
  • Now you can safely remove the old IP address if required
  1. To change the Cluster Access Point IP address:
  • From the properties of the cluster name – click on ADD to add new IP address in the new subnet
  • Make sure that the IP address is online
  • If everything is fine, then you can safely remove the old IP.

For my client, this whole process took down around 15 minutes. Hope this would help you in planning such activity.

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

First appeared on SQL SERVER – Steps to Change IP Address of SQL Server Failover Cluster Instance

SQL SERVER – Get List of the Logical and Physical Name of the Files in the Entire Database

$
0
0

One of the most popular questions I often receive is why do I like to do consultation – my answer is very simple – it gives me an opportunity to learn continuously learn new things from my clients. Here is a script which I have built during my recent Comprehensive Database Performance Health Check. To perform one of the performance tuning tasks we needed a list of all the logical and physical names for the files for every single database on the SQL Server Instance. Here is the script which can list all the physical and logical name of the files along with their type as well.

SQL SERVER - Get List of the Logical and Physical Name of the Files in the Entire Database logicalfilename

SELECT d.name DatabaseName, f.name LogicalName,
f.physical_name AS PhysicalName,
f.type_desc TypeofFile
FROM sys.master_files f
INNER JOIN sys.databases d ON d.database_id = f.database_id
GO

You can see the result of the script here.

SQL SERVER - Get List of the Logical and Physical Name of the Files in the Entire Database logicalfilename

In the result set, you can see database name, logical file name, physical file name, and type of the file.

The reason, I decided to blog about this script because even though it is a very simple script I was particular, not able to find such script online. I believe sometimes we skip learning a simple script and write a complicated script.

If you have any similar script which is simple and you use daily, please send them to me. I will blog them with the due credit to you.

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

First appeared on SQL SERVER – Get List of the Logical and Physical Name of the Files in the Entire Database

SQL SERVER – OLE DB Provider ‘Microsoft.ACE.OLEDB.12.0’ for Linked Server ‘(null)’ Returned Message ‘Unspecified Error’

$
0
0

SQL SERVER - OLE DB Provider 'Microsoft.ACE.OLEDB.12.0' for Linked Server '(null)' Returned Message 'Unspecified Error' oledberror There are many situations where you have to create a linked server to Microsoft Excel and read data from there. While doing that, I encountered an error and in this blog, we would discuss how to fix OLE DB provider ‘Microsoft.ACE.OLEDB.12.0’ for linked server ‘(null)’ returned message ‘Unspecified error’

Below query can read data from excel in a shared location.

SELECT * FROM OPENROWSET(
'Microsoft.ACE.OLEDB.12.0'
,'Excel 12.0;Database=\\\\FileServer\\ExcelShare\\HRMSDATA.xlsx;HDR=YES;IMEX=1'
,'SELECT * FROM [EMPMASTER$]')

This was failing with error:

OLE DB provider ‘Microsoft.ACE.OLEDB.12.0’ for linked server ‘(null)’ returned message ‘Unspecified error’.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider ‘Microsoft.ACE.OLEDB.12.0’ for linked server ‘(null)’.

SOLUTION/WORKAROUND

Based on my search on the internet, we were not seeing DisallowAdHocAccess registry key under.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL14.MSSQLSERVER\Providers\Microsoft.ACE.OLEDB.12.0

We then executed below command and key got created automatically.

USE [master]
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DisallowAdHocAccess', 0
GO

After this, we were able to read data from excel without any error.

If you find some other solution, please share via comments.

Here are a few other blog post related to the same subject:

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

First appeared on SQL SERVER – OLE DB Provider ‘Microsoft.ACE.OLEDB.12.0’ for Linked Server ‘(null)’ Returned Message ‘Unspecified Error’

Data Privacy – Are Your Database Processes Fully Compliant?

$
0
0

This year has been filled with data privacy and protection concerns. From the introduction of the General Data Protection Regulation (GDPR) and the exposure of data breaches at Cambridge Analytica, Facebook and Under Armour, to new legislation springing up in the US, including New York’s Stop Hacks and Improve Electronic Data Security Act (SHIELD) and the California Consumer Privacy Act (CCPA). Stories about the value of data – and the risks associated with it – are everywhere. As data professionals, the pressure is there to achieve a balance between compliance and the need to deliver faster than ever.

Data Privacy - Are Your Database Processes Fully Compliant? dataprovision

Compliance is more than cybersecurity: it involves a shift in the way business is done. One common misconception is that threats to data are purely external, yet insider error or breaches account for a large proportion of data exposure. So simply implementing antivirus or antimalware isn’t enough. Procedures must be put in place where the data lives – at the database level. Unfortunately, these same measures can also cause bottlenecks at release time.

To best reap the rewards of data, without impacting performance, it’s crucial to understand what is required of you as an employee and as a business in terms of regulatory demands.

The first step is getting wise on your respective legislation – being familiar with data laws is no longer restricted to the lawyers. The second step is to revisit your own systems to identify gaps in security, highlight weak points and possible risk factors and ensure they are fully compliant.  And finally, do your research. Reach out to the community, see how others are handling the issue and turn to industry experts.

Microsoft MVP Grant Fritchey recently wrote a free to download whitepaper for Redgate Software. While he discusses US legislation in this whitepaper, it provides best practices for the data professional, with insight and guidance into how to approach data compliance, regardless of the legislation.  If you want to find out how compliant you really are with data protection regulations, it could be a good place to start.

Check out the whitepaper

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

First appeared on Data Privacy – Are Your Database Processes Fully Compliant?


SQL SERVER – SQL Server Agent Missing in SQL Server Management Studio (SSMS)

$
0
0

Learning never stops when you are a consultant. While doing my recent Comprehensive Database Performance Health Check my client asked an interesting question. He informed that he is not able to see SQL Server Agent node in SQL Server Management Studio (SSMS). What could be the possible cause? I was able to provide him answers and sharing it here. First, let us understand what he meant.  If you look closer at two SSMS connection. Do you notice a difference? Yes. As the title says – SQL Server Agent is missing in the second image. So, what are the possible causes?

SQL SERVER - SQL Server Agent Missing in SQL Server Management Studio (SSMS) agt-miss-01

SQL SERVER - SQL Server Agent Missing in SQL Server Management Studio (SSMS) agt-miss-02

POSSIBLE CAUSES

  1. If the Login account connecting to SSMS is not a part of SysAdmin role in SQL Server, then SQL Server Agent would not be visible?

To verify, you can run below query in SQL Server Management Studio and check the output.

Select IS_SRVROLEMEMBER('Sysadmin')

SQL SERVER - SQL Server Agent Missing in SQL Server Management Studio (SSMS) agt-miss-03

If a value is zero, then you are not a Sysadmin and hence you can’t see SQL Server Agent. Image shows the same behavior.

  1. Another possible reason would be that SQL Server in not an edition which supports SQL Server Agent. Typically, SQL Server Express edition could be another cause.

To verify, you can run below query in SQL Server Management studio and check the output.

SELECT SERVERPROPERTY('Edition')

If above returns “Express” or “Express Edition with Advanced Services”, then you would not see SQL Server Agent node in SSMS.

These are the only two reasons I found due to which you won’t see Agent node in SSMS. If you have found some more causes, please share it with others via comments.

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

First appeared on SQL SERVER – SQL Server Agent Missing in SQL Server Management Studio (SSMS)

SQL SERVER – What is the Meaning of PREEMPTIVE_HTTP_EVENT_WAIT? How to Fix it?

$
0
0

While playing with my SQL Server in Azure VM, I faced an interesting issue.  I did some change in networking to avoid internet access by creating an outbound rule and then I started facing this issue. In this blog, I would explain one of the possible causes of PREEMPTIVE_HTTP_EVENT_WAIT.

THE SITUATION

I have a SQL Server in Azure Virtual Machine. For learning purpose, I wanted to block internet access on the Virtual machine. So, I created an outbound rule to block internet access with “deny” option – as shown below.

SQL SERVER - What is the Meaning of PREEMPTIVE_HTTP_EVENT_WAIT? How to Fix it? prem-01

Above rule works fine and I was able to achieve what I wanted. I was unable to open any site, including google.com

SQL SERVER - What is the Meaning of PREEMPTIVE_HTTP_EVENT_WAIT? How to Fix it? prem-02

THE PROBLEM

Since I blocked outbound internet access, my backups to URL started to give me trouble. Whenever I start back up, it runs for a long time (which used to finish in a few seconds). I executed below query to find out what is happening in SQL and found below.

The two wait types are

  • BACKUPTHREAD
  • PREEMPTIVE_HTTP_EVENT_WAIT

SQL SERVER - What is the Meaning of PREEMPTIVE_HTTP_EVENT_WAIT? How to Fix it? prem-03

I could not find any documentation for PREEMPTIVE_HTTP_EVENT_WAIT but from the wait, it looks like this wait would not end by itself like they way SQL threads work. It also seems like its waiting for some http request which must have gone out to storage due to my backup to https. Here is the backup command.

BACKUP DATABASE SQLAuthDB TO  
URL = N'https://sqlauthority.blob.core.windows.net/backupcontainer/SQLAuthDB.bak'
GO

As you can see, I am taking backup of database using Backup to URL feature and it should go to my storage account. Since the backup would also go out of the machine, it would use the internet, which I blocked on this Virtual Machine. I waited for around 20 minutes and finally backup failed with below message.

Msg 3201, Level 16, State 1, Line 1
Cannot open backup device ‘https://sqlauthority.blob.core.windows.net/backupcontainer/SQLAuthDB.bak’. Operating system error 50(The request is not supported.).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.

Now, I know that I broke backup to URL by blocking internet? Does it mean I must have internet access on the Virtual machine? Or there is something else I can do?

THE SOLUTION

After my search on the internet, I found two ways to solve this by keeping the existing rule.

  1. Open specific port and put the rule priority lesser than internet rule. In our case, we are using https which uses 443 port.
  2. Add an outbound rule for storage and allow connections to go out even though the internet is blocked.

Option 2 is better as it takes care of port number automatically. So, I change my internet rule priority to 200 and added a new rule with destination as “Storage”

SQL SERVER - What is the Meaning of PREEMPTIVE_HTTP_EVENT_WAIT? How to Fix it? prem-04

…after this, google.com was not opening but backup to URL started working!

SQL SERVER - What is the Meaning of PREEMPTIVE_HTTP_EVENT_WAIT? How to Fix it? prem-05

So now, whenever you see PREEMPTIVE_HTTP_EVENT_WAIT, start checking about what kind of query is going to the internet. If it’s a backup to URL then you know the answer now.

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

First appeared on SQL SERVER – What is the Meaning of PREEMPTIVE_HTTP_EVENT_WAIT? How to Fix it?

SQL SERVER – The OLE DB Provider “Microsoft.ACE.OLEDB.12.0” for Linked Server “(null)” Reported an Error. Access Denied

$
0
0

Here is another blog which explains a situation I was in while reading data from excel. In this blog, we would talk about error “Access Denied” error while using The OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server.

I was using the following query to read the data from excel. Filename “SQLAuthority.xlsx” and sheet name was “Sheet1”.

SELECT * FROM OPENROWSET(
'Microsoft.ACE.OLEDB.12.0'
,'Excel 12.0;Database=F:\Backup\SQLAuthority.xlsx;HDR=YES'
,'SELECT * FROM [Sheet1$]')

The error message while running the query is as follows.

Msg 7399, Level 16, State 1, Line 1
The OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)” reported an error. Access denied.
Msg 7350, Level 16, State 2, Line 1
Cannot get the column information from OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)”.

If you observe in the image, the path, file name etc. are correct.

SQL SERVER - The OLE DB Provider "Microsoft.ACE.OLEDB.12.0" for Linked Server "(null)" Reported an Error. Access Denied excel-ad-01

Here is the content of the excel file.

SQL SERVER - The OLE DB Provider "Microsoft.ACE.OLEDB.12.0" for Linked Server "(null)" Reported an Error. Access Denied excel-ad-02

Since we can see “Access Denied” in the message, I tried all possible permissions to file, folder, everyone, full control etc. but none helped. I also tried explicit permission to service account NT Service\MSSQLSERVER.

SOLUTION/WORKAROUND

As I mentioned, I checked service account and it was set as NT Service\MSSQLSERVER.

I changed that to Local System as shown below and restarted the service.

SQL SERVER - The OLE DB Provider "Microsoft.ACE.OLEDB.12.0" for Linked Server "(null)" Reported an Error. Access Denied excel-ad-03

And then it started working.

SQL SERVER - The OLE DB Provider "Microsoft.ACE.OLEDB.12.0" for Linked Server "(null)" Reported an Error. Access Denied excel-ad-04

Have you seen this error and found some other solution? If yes, please write in the comment box below to help others.

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

First appeared on SQL SERVER – The OLE DB Provider “Microsoft.ACE.OLEDB.12.0” for Linked Server “(null)” Reported an Error. Access Denied

SQL SERVER – Unable to Uninstall – Index was Outside the Bounds of the Array

$
0
0

This was an interesting error which I received while trying to uninstall SQL Server.  In this blog, we would learn how to fix error Index was outside the bounds of the array, which might come during uninstallation of SQL Server.

I must say this was an unfortunate situation where my machine got crashed while SQL Server install was in progress. To get rid of the “incomplete” installation, I decided to remove it and install it again. I went to add/remove program and selected “uninstall” for SQL Server 2017 as I was welcomed by error – Index was outside the bounds of the array. I looked into Summary.txt file and found below.

Overall summary:
Final result: Failed: see details below
Exit code (Decimal): -2146233080
Exit facility code: 19
Exit error code: 5384
Exit message: Index was outside the bounds of the array.
Requested action: Uninstall

Further, I could see below in the same log.

SQL SERVER - Unable to Uninstall - Index was Outside the Bounds of the Array out-of-bound-01

This was the exception

Exception type: System.IndexOutOfRangeException
Message: Index was outside the bounds of the array.
HResult : 0x80131508
Stack:
at Microsoft.SqlServer.Configuration.InstallWizard.InstanceSelectionController.SaveData()
at Microsoft.SqlServer.Configuration.InstallWizardFramework.InstallWizardPageHost.PageLeaving(PageChangeReason reason)
at Microsoft.SqlServer.Configuration.WizardFramework.UIHost.set_SelectedPageIndex(Int32 value)
at Microsoft.SqlServer.Configuration.WizardFramework.NavigationButtons.nextButton_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Detail.txt also showed similar information

(06) 2018-11-25 09:48:24 Slp: Sco: Attempting to open registry subkey Software\Microsoft\Microsoft SQL Server\Instance Names
(06) 2018-11-25 09:48:24 Slp: Sco: Attempting to open registry subkey SQL
(06) 2018-11-25 09:48:24 Slp: Sco: Attempting to get registry value
(06) 2018-11-25 09:48:24 Slp: Sco: Attempting to open registry subkey OLAP
(06) 2018-11-25 09:48:24 Slp: Sco: Attempting to get registry value
(06) 2018-11-25 09:48:24 Slp: Sco: Attempting to open registry subkey RS
(06) 2018-11-25 09:48:24 Slp: No installed instance features found for InstanceName = ”
(06) 2018-11-25 09:48:24 Slp: Final InstallID = ‘cba7cce5-c24c-463d-8608-08fc78c8e678’
(06) 2018-11-25 09:48:24 Slp: End calculate InstallID
(01) 2018-11-25 09:48:27 Slp: Error: Action “Microsoft.SqlServer.Configuration.UIExtension.WaypointAction” threw an exception during execution.

WORKAROUND/SOLUTION

It was clear from the log that installation didn’t reach to the stage where it has to be configured. That’s why we are seeing <UNCONFIGURED> for the instance name.

Instead of UI, I decided to use the command line to install. So, I went to below folder.

C:\Program Files\Microsoft SQL Server\140\Setup Bootstrap\SQL2017

And use below the line in command prompt.

SETUP.EXE /ACTION=UNINTSALL

This time, I was able to get to the UI and choose “<UNCONFIGURED>” instance

SQL SERVER - Unable to Uninstall - Index was Outside the Bounds of the Array out-of-bound-02

… and remove SQL successfully.  

I was unable to find out this trick on the internet. Hopefully, this would help someone who needs it.

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

First appeared on SQL SERVER – Unable to Uninstall – Index was Outside the Bounds of the Array

SQL SERVER – SETUP Error: The Syntax of Argument “/ACTION” is Incorrect

$
0
0

Recently, I was trying to uninstall SQL Server via command prompt and faced an interesting situation. In this blog, we would learn about the error “The syntax of argument “/ACTION” is incorrect” and how to fix it.

THE SITUATION

As I mentioned in one of my recent blogs, due to a reboot of the server in the middle of the installation, I was supposed to clean up. UI didn’t work, and I decided to use the command line.

As soon as I provided a command to uninstall SQL Server, it gave below error.

SQL SERVER - SETUP Error: The Syntax of Argument "/ACTION" is Incorrect setup-cmd-fail-01

The text of the message is as below.

SQL Server Setup has encountered the following error:
The syntax of argument “/ACTION” is incorrect. Either the delimiter ‘=’ is missing or there is one or more space characters before the delimiter ‘=’. Please use /? to check usage.
Error code 0x84B40001.

One we hit OK, we get below on command prompt.

SQL SERVER - SETUP Error: The Syntax of Argument "/ACTION" is Incorrect setup-cmd-fail-02

The text is as follows.
C:\>”C:\Program Files\Microsoft SQL Server\140\Setup Bootstrap\SQL2017\setup.exe” /ACTION = UNINSTALL
The following error occurred:
The syntax of argument “/ACTION” is incorrect. Either the delimiter ‘=’ is missing or there is one or more space characters before the delimiter ‘=’. Please use /? to check usage.

Error result: -2068578303
Result facility code: 1204
Result error code: 1
Please review the summary.txt log for further details

Even though message says refer Summary.txt, there was no such file create on the location where generally setup logs are located. Then I referred documentation and found that there must be some file in the TEMP folder.  I was able to find a file in my profile temp folder. You can go to Start > Run > and Type %TEMP% and look for a file called “SqlSetup_Local.log” exact same modified time when setup was invoked.

Here is the content of the file. I have removed time stamp for clarity.

Setup launched
Attempting to determine media source
Media source value not specified on command line argument and this setup is not running from media directly.
Assume no media info is needed. Exit
Setup.exe is running locally no check for a slip stream media
/? or /HELP or /ACTION=HELP specified: false
Help display: false
.Net version 4.0 is installed
Name verification using runtime version v4.0.30319
Strong name verification disabling is not required
/? or /HELP or /ACTION=HELP specified: false
Help display: false
Attempting to launch landing page workflow
Attempting to set setup mutex
Setup mutex has been set
Attempting to launch user requested workflow from media
Attempting to get execution timestamp
Timestamp: 20181126_055331
Attempting to run user requested action from media ScenarioEngine.exe
Attempting to launch process C:\Program Files\Microsoft SQL Server\140\Setup Bootstrap\SQL2017\x64\ScenarioEngine.exe
Process returned exit code: 0x84B40001
Media ScenarioEngine.exe returned exit code: 0x84B40001
Attempting to release setup mutex
Setup mutex has been released
Setup closed with exit code: 0x84C40013

This also doesn’t help much.

SOLUTION/WORKAROUND

I read error message again and it was #FacePalm situation. I will put a message here again and you might feel the same.

The syntax of argument “/ACTION” is incorrect. Either the delimiter ‘=’ is missing or there are one or more space characters before the delimiter ‘=’. Please use /? to check usage.

The message clearly says that don’t use space characters. My command was

“C:\Program Files\Microsoft SQL Server\140\Setup Bootstrap\SQL2017\setup.exe” /ACTION = UNINSTALL

If I do setup.exe /? I see below the line.

Usage:

 setup.exe /[option]={value} /[option]={value} …

So, the right command would be

“C:\Program Files\Microsoft SQL Server\140\Setup Bootstrap\SQL2017\setup.exe” /ACTION=UNINSTALL

Note that I have removed space. Have you faced such a situation where adding extra space causes a problem?

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

First appeared on SQL SERVER – SETUP Error: The Syntax of Argument “/ACTION” is Incorrect

Viewing all 594 articles
Browse latest View live