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

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

$
0
0

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

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

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

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

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

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

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

WORKAROUND / SOLUTION

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

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

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


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

$
0
0

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

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

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

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

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

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

WORKAROUND/SOLUTION

I checked below key based on the article

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

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

Windows Registry Editor Version 5.00

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

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

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

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

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

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

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

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

$
0
0

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

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

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

SOLUTION/WORKAROUND

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

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

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

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

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

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

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

SQL SERVER – Availability Group Missing or Deleted Automatically?

$
0
0

SQL SERVER - Availability Group Missing or Deleted Automatically? missing As a part of my passion, I try to help people in fixing simple issues and explain the behavior by looking at logs. Here is an email from my friend about Availability Group Missing or Deleted Automatically.

Pinal,
We need your services again to help us understand the cause of a strange issue.

We had a network issue earlier today. After that we observed that there were two availability groups that were not only down, but also no longer even listed under the Availability Groups in SQL Server Management Studio. When we checked failover cluster manager, they do show up under Services and Applications in the Failover Cluster Manager but in failed states. It is interesting that on the node that has missing AGs, the databases show up as “Restoring”

Just to make sure it’s not a ghost effect, we have tried SQL Server service restarts and reboots but the fault is unchanged.

Any quick ideas?

Thanks,
John

Since this was an interesting issue, I asked John to share the SQL Server ERRORLOG SQL SERVER – Where is ERRORLOG? Various Ways to Find ERRORLOG Location

I looked into ERRORLOG and found below interesting message on the replica where AG was missing.

2017-02-26 13:26:43.08 spid38s Error: 19435, Severity: 16, State: 1.
2017-02-26 13:26:43.08 spid38s AlwaysOn: WSFC AG integrity check failed for AG ‘PROD_AG’ with error 41041, severity 16, state 0.
2017-02-26 13:26:43.08 spid38s AlwaysOn: The local replica of availability group ‘PROD_AG’ is being removed. The instance of SQL Server failed to validate the integrity of the availability group configuration in the Windows Server Failover Clustering (WSFC) store. This is expected if the availability group has been removed from another instance of SQL Server. This is an informational message only. No user action is required.
2017-02-26 13:26:43.08 spid38s The state of the local availability replica in availability group ‘PROD_AG’ has changed from ‘SECONDARY_NORMAL’ to ‘NOT_AVAILABLE’. The replica state changed because of either a startup, a failover, a communication issue, or a cluster error. For more information, see the availability group dashboard, SQL Server error log, Windows Server Failover Cluster management console or Windows Server Failover Cluster log.

CONCLUSION

From the above message, I think, SQL was not able to communicate with Windows cluster and as a safe guard the availability group was removed from SQL.

If this happens, there is no data loss. We just need to recover databases, if needed and drop AG completely. Once cleanup is successful, it should be easy to reconfigure availability group.

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

First appeared on SQL SERVER – Availability Group Missing or Deleted Automatically?

SQL SERVER – Microsoft.SqlServer.Management.Sdk. Sfc.EnumeratorException: Failed to Retrieve Data for This Request

$
0
0

If you work with a product for a long time, you would start loving it. I have worked with many other RDBMS, but my love to SQL Server will never die. The amount of information available in logs is very helpful and can help in pointing the exact issue related to retrieve data.

One of my clients was installing Service Pack on a clustered SQL instance and it was failing. I looked into Detail.txt and found below information.

2017-02-28 11:03:44 Slp: Running Action: RunDiscoveryAction
2017-02-28 11:03:44 Slp: Running discovery on local machine
2017-02-28 11:03:47 Slp: Discovery on local machine is complete
2017-02-28 11:03:47 Slp: Running discovery on remote machine: SQLNODE-B
2017-02-28 11:05:21 Slp: Discovery on SQLNODE-B failed due to exception
2017-02-28 11:05:21 Slp: Microsoft.SqlServer.Management.Sdk.Sfc.EnumeratorException: Failed to retrieve data for this request. —> Microsoft.SqlServer.Configuration.Sco.SqlRegistryException: The network path was not found.

Based on my understanding of .net, the stack goes from bottom to top. If we look at functions called, it looks like a Registry call to get details from remote nodes. It seems that in order to complete the remote discovery, setup has to read the registry of the remote node. We attempted to open the registry on node SQLNODE-B from registry editor on node SQLNODE-A. (Start > run > Regedit)

SQL SERVER - Microsoft.SqlServer.Management.Sdk. Sfc.EnumeratorException: Failed to Retrieve Data for This Request reg-remote-01

As soon as we gave the remote node name, it failed to open the registry and gave the same error.

SOLUTION/WORKAROUND

We realized that “Remote Registry” service was “Disabled” on remote node. Enabling that, solved the problem.

SQL SERVER - Microsoft.SqlServer.Management.Sdk. Sfc.EnumeratorException: Failed to Retrieve Data for This Request reg-remote-02-800x344

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

First appeared on SQL SERVER – Microsoft.SqlServer.Management.Sdk. Sfc.EnumeratorException: Failed to Retrieve Data for This Request

SQL SERVER – DBCC SHRINKFILE: Page 1:26423878 Could not be Moved Because it is a Work Table Page – TempDB Files

$
0
0

SQL SERVER - DBCC SHRINKFILE: Page 1:26423878 Could not be Moved Because it is a Work Table Page - TempDB Files tempdb This blog is an outcome of an email communication with my client. The issue was that they were having big tempdb files. They had multiple files and of uneven size. As soon as they restart SQL, the initial size itself was huge and when they tried to shrink the TempDB database, it was not doing anything. Here was the message in SQL Server Management Studio query window.

DBCC SHRINKFILE (1,1024)

DBCC SHRINKFILE: Page 1: 26423878 could not be moved because it is a work table page.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

If we try to covert page number to location in MDF file, it was 26423878 * 8 KB = ~201 GB and that was the size on which they were stuck. We were seeing same page every time we try to shrink, even after restart of SQL Server. What was the option now?

WORKAROUND/SOLUTION

Please note that you try everything out on your development server before experimenting on the production server.

We need to restart SQL with a special switch -f which is used to start SQL with minimal configuration. Note: this needs downtime of SQL Server for some time as no one should connect to SQL.

  • Stop SQL Server service.
  • Start SQL Server in minimal mode from command prompt.
NET START MSSQLSERVER /f /mSQLCMD
  • Above command starts SQL Server in minimal configuration (f switch) and allows connections from the application named SQLCMD (mSQLCMD)
  • Connect to SQL using SQLCMD
  • In the SQLCMD connection, execute the following command for each one of the tempdb data files to set their initial size to 500 MB and file growth also to 500 MB increments.
ALTER DATABASE [tempdb] MODIFY FILE (NAME = N'tempdev',SIZE=500MB, FILEGROWTH = 500MB )
GO
  • Repeat this process for every tempdb data file.
  • Now verify the initial size has taken effect using the following query.
SELECT name ,size*8.0/1024  'Initial Size in MB'
FROM master.sys.sysaltfiles WHERE dbid = 2
  • Once size has come down to expected size, we need to stop SQL service NET STOP MSSQLSERVER
  • And now, start again normally.
  • Relax as tempdb size has been reduced.

Note: MSSQLSERVER in the above command is for the default instance. So, if you have named instance, it would be MSSQL$InstanceName

Have you ever seen such error during shrink? Did you find another way?

Please note that Shrinking Database is not recommended process and it can lead to slowest possible performance. You must read this article Shrinking Database is Bad – Increases Fragmentation – Reduces Performance.

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

First appeared on SQL SERVER – DBCC SHRINKFILE: Page 1:26423878 Could not be Moved Because it is a Work Table Page – TempDB Files

SQL SERVER – AlwaysOn Listener Error – The WSFC Cluster Could Not Bring the Network Name Resource With DNS Name ‘DNS name’ Online

$
0
0

I can tell you how many times I have heard about this error. This can appear in any of the situation where SQL needs to create a cluster network name resource in the WSFC Cluster. Here are the two situations I can think of:

  1. Installing SQL Server Failover Cluster instance.
  2. Creating listener in the AlwaysOn availability group.

Below is the error which was sent by one of my clients. This appeared while creating listener from management studio.

SQL SERVER -  AlwaysOn Listener Error - The WSFC Cluster Could Not Bring the Network Name Resource With DNS Name 'DNS name' Online listener-error-01

Here is the text of the message.

The WSFC cluster could not bring the Network Name resource with DNS name ‘<DNS name>’ online. The DNS name may have been taken or have a conflict with existing name services, or the WSFC cluster service may not be running or may be inaccessible. Use a different DNS name to resolve name conflicts, or check the WSFC cluster log for more information.

The attempt to create the network name and IP address for the listener failed. The WSFC service may not be running or may be inaccessible in its current state, or the values provided for the network name and IP address may be incorrect. Check the state of the WSFC cluster and validate the network name and IP address with the network administrator.

Above error can be caused due to many reasons which can cause network name or client access point resource in cluster creation to fail. 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 prestaging of virtual computer object (VCO) in domain controller.

  • If possible, connect to 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.

What are the other errors you have seen while creating listener?

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

First appeared on SQL SERVER – AlwaysOn Listener Error – The WSFC Cluster Could Not Bring the Network Name Resource With DNS Name ‘DNS name’ Online

SQL SERVER – Jump in Identity Column After Restart

$
0
0

The SQL Product team makes a continuous change in the product which sometimes causes unpredictable behaviors in the SQL Server engine. One of such change was done in SQL Server 2012 which caused the behavior which I just said in the subject line Identity Column.

Here are steps to simulate the behavior. I did it on SQL 2012.

--Create a test database.
CREATE DATABASE TestIdentityDB

--Create a test table in above database with auto identity column
USE TestIdentityDB
GO
CREATE TABLE MyTable (
	 id INT identity
	,name VARCHAR(10)
	)
GO

--Insert a row in the table
INSERT INTO MyTable (name)
VALUES ('Pinal')

SELECT *
FROM MyTable

--Restart SQL Server service and once completed, insert another record.
INSERT INTO MyTable (name)
VALUES ('Dave')

--Let's select data from table now.
SELECT * FROM MyTable

SQL SERVER - Jump in Identity Column After Restart identity-01

You would expect the value to be in order, but as you can see there is a jump in the identity value.

I searched on the Web and as per Microsoft documentation, identity is not guaranteed to give sequential value. In SQL Server 2012 the implementation of the identity property has been changed to accommodate investments into other features. This is what they have mentioned in a connect item, “In previous versions of SQL Server the tracking of identity generation relied on transaction log records for each identity value generated. In SQL Server 2012 we generate identity values in batches and log only the max value of the batch. This reduces the amount and frequency of information written to the transaction log improving insert scalability.”

Above means that this is expected behavior because identity values are cached and destroyed on restart/failover.

WORKAROUND/SOLUTION

As per Microsoft documentation we should use SEQUENCE object with NOCACHE option. You can refer below blog for more details.

Another option which we have is to use trace flag 272 by adding -T272 as SQL Server Startup Parameter in the configuration manager.

Here are the reference articles.

https://connect.microsoft.com/SQLServer/feedback/details/739013/failover-or-restart-results-in-reseed-of-identity

http://msdn.microsoft.com/en-us/library/ff878091.aspx

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

First appeared on SQL SERVER – Jump in Identity Column After Restart


SQL SERVER – Could Not Use View or Function ‘msdb.dbo.sysdac_instances’ Because of Binding Errors

$
0
0

This error is one of an interesting which appeared as soon as we right click on the database. It says Could Not Use View or Function ‘msdb.dbo.sysdac_instances’ Because of Binding Errors.

Due to this error, we were not able to see the properties of the database. Interesting this was happening only when we use the latest version of SQL Server Management Studio 2012. Which made me think that SSMS 2012 automatically checks this view before opening the ‘right click’ menu of a database.

SQL SERVER - Could Not Use View or Function 'msdb.dbo.sysdac_instances' Because of Binding Errors colla-err-01

We captured profile and found that the error was raised while using this view.

CREATE VIEW [dbo].[sysdac_instances]
AS
    SELECT
        -- this must be locked down because we use instance_id visability as a security gate
        case
            when (dbo.fn_sysdac_is_currentuser_sa() = 1) then dac_instances.instance_id
            when sd.owner_sid = SUSER_SID() then dac_instances.instance_id
            else NULL
        end as instance_id,
        dac_instances.instance_name,
        dac_instances.type_name,
        dac_instances.type_version,
        dac_instances.description,
        case
            when (dbo.fn_sysdac_is_currentuser_sa() = 1) then dac_instances.type_stream
            when sd.owner_sid = SUSER_SID() then dac_instances.type_stream
            else NULL
        end as type_stream,
        dac_instances.date_created,
        dac_instances.created_by,
        dac_instances.instance_name as database_name
    FROM sysdac_instances_internal dac_instances
    LEFT JOIN sys.databases sd
              ON dac_instances.instance_name = sd.name

As per the above View we see join on “ON dac_instances.instance_name = sd.name”. Here sys.databases are coming from MASTER database and sysdac_instances is from MSDB database. We have queried sys.database and found the collation was different as seen below.

master:  Latin1_General_CI_AI

msdb: SQL_Latin1_General_CP1_CI_AS

Now we know the cause of the error. Later we identified that MSDB was restored from a different server, which caused this issue.

WORKAORUND/SOLUTION

There is no easy way to change collation of system databases. To rebuild the system databases for an instance of SQL Server we need to run setup.exe with below parameters.

Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=InstanceName /SQLSYSADMINACCOUNTS=accounts [ /SAPWD= StrongPassword ] [ /SQLCOLLATION=CollationName]

Once completed, we restored the backups which we have taken before rebuilding system databases. We should take care of objects which are there in system databases before running rebuild command.

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

First appeared on SQL SERVER – Could Not Use View or Function ‘msdb.dbo.sysdac_instances’ Because of Binding Errors

SQL SERVER – The Lease between Availability Group ‘PRODAG’ and the Windows Server Failover Cluster has Expired

$
0
0

This is one of the common errors I have seen while working with customers who are using SQL Server AlwaysOn availability groups. Once this error comes, the resource in the cluster goes to failed state and in SQL Server Management Studio, we should be an availability group in resolving state. Resolving state essentially means that the role of availability group is neither primary nor secondary.

SQL SERVER - The Lease between Availability Group 'PRODAG' and the Windows Server Failover Cluster has Expired AlwaysOn-800x201

Here is the snippet from ERRORLOG when the lease expires. I have tried to explain the meaning of each line.

2017-02-27 19:31:07.34 Server Error: 19407, Severity: 16, State: 1.
2017-02-27 19:31:07.34 Server The lease between availability group ‘PRODAG’ and the Windows Server Failover Cluster has expired. A connectivity issue occurred between the instance of SQL Server and the Windows Server Failover Cluster. To determine whether the availability group is failing over correctly, check the corresponding availability group resource in the Windows Server Failover Cluster.

Above message means the lease between windows cluster and SQL Server.

2017-02-27 19:31:07.34 Server      AlwaysOn: The local replica of availability group ‘PRODAG’ is going offline because either the lease expired or lease renewal failed. This is an informational message only. No user action is required.

Due to lease renewal failure, the AG resource in the cluster would go to failed state.

2017-02-27 19:31:07.34 Server      The state of the local availability replica in availability group ‘PRODAG’ has changed from ‘PRIMARY_NORMAL’ to ‘RESOLVING_NORMAL’.  The state changed because the lease between the local availability replica and Windows Server Failover Clustering (WSFC) has expired.  For more information, see the SQL Server error log, Windows Server Failover Clustering (WSFC) management console, or WSFC log.

Since AG is failed, the AG state in SQL Server would change from PRIMARY to RESOLVING_NORMAL. At the same time, on secondary, we should see state from SECONDARY_NORMAL to RESOLVING_NORMAL

Now the next challenge would be to find WHY lease was expired.

SOLUTION/WORKAROUND

Based on my research on the internet, I found that in most of the cases, the lease gets expired due to shortage of resources on the machine. You can think of this as a “momentarily hang” of windows operations. Generally, we should look at the cause of slowness. The client with whom I worked, I could see tons of IO related messages like below.

2017-02-27 19:23:26.09 spid35s     SQL Server has encountered 244 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [M:\MSSQL\SAM_PRODUCTION.MDF] in database id 21.  The OS file handle is 0x0000000000001B44.  The offset of the latest long I/O is: 0x00004fcfb76000

I have explained above issue in below blog SQL SERVER – WARNING – SQL Server Has Encountered N Occurrence(s) of I/O Requests Taking Longer Than 15 Seconds

We also saw below, which again points to IO slowness.

2017-02-27 19:31:05.09 spid18s                 average writes per second: 1225.28 writes/sec
average throughput:  86.19 MB/sec, I/O saturation: 149511, context switches 190629
2017-02-27 19:31:05.09 spid18s                 last target outstanding: 278, avgWriteLatency 38

Till you find the actual cause, you can increase LeaseTimeout value so that the AG is remaining healthy

But remember that we have not fixed the issue, but applied band-aid.

Here are few more things to do.

  • Limit Max Server Memory of SQL Server, if not capped.
  • Consult your storage team for storage performance issues, since we see many IO stalled messages.
  • Enable lock pages in memory. This will prevent work set trimming and prevent it from being paged out.  Please refer to the below link https://msdn.microsoft.com/en-IN/library/ms190730.aspx

Have you found something more than above?

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

First appeared on SQL SERVER – The Lease between Availability Group ‘PRODAG’ and the Windows Server Failover Cluster has Expired

SQL SERVER – Huge Size of Table catalog.execution_component_phases in SSISDB

$
0
0

Have you ever faced a situation where the table size in SSISDB is very huge? Are you are wondering what this SSISDB database is? It has information about the SSIS catalog execution and we should not truncate them as they belong to SSIS subsystem. Once I faced a situation where I could see SSISDB was very huge in size. When looking for more help, I found under the MSDN link which talks about the table. https://technet.microsoft.com/en-us/library/hh230981.aspx

This table displays the time spent by a data flow component in each execution phase.

Since the size of this table was huge, I found below reasons.

  1. Retention period: By default, the retention period is set to 365 days. We can change this value to some lower number (the number of days we want to retain these logging data)
  2. Logging Level: There are various logging levels, which can be used to debug the package execution. If things are looking good, then None can be set.
  3. Clean logs periodically: As the name suggests, we should set to True for size of SSISDB

All of the above can be controlled using properties.

SQL SERVER - Huge Size of Table catalog.execution_component_phases in SSISDB ssisdb-size-01

  1. Package’s Logging Level: In earlier step # 2, we have configured default logging level, which can be overwritten by the package itself. Here are the steps to check and set that.
    1. In SQL Server Management Studio, navigate to the package in Object Explorer.
    2. Right-click the package and select Execute.
    3. Select the Advanced tab in the Execute Package dialog box.
    4. Under Server-wide Default Logging level, requested to set the value to “None”
  2. We can do custom logging in an SSIS as shown below.

SQL SERVER - Huge Size of Table catalog.execution_component_phases in SSISDB ssisdb-size-02

  1. Full cleanup: We can also use below procedure to cleanup complete history for all.
EXEC SSISDB.internal.cleanup_server_log

Since I am not an expert in SSIS, are there any other knobs available?

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

First appeared on SQL SERVER – Huge Size of Table catalog.execution_component_phases in SSISDB

SQL SERVER – Express and SQL Server Agent – Free Alternative

$
0
0

“How come my database is only a few MBs big and I am facing performance problems?” My customer asked. I replied, “Well, this is because you are not running job using SQL Server Agent to keep your indexes in the best health.”

This is a very common conversation I usually have with my customers who are facing issues with SQL Server Performance. However, recently I had a very interesting conversation with my customer. He suggested, how come he run Maintenance Job when he is using SQL Server Express, which does not have SQL Server Agent. A very valid point.

If you are using SQL Server Express, it does not come with SQL Server Agent. However, this should not be the reason to get disheartened. There are many different alternatives available out there, but my favorite alternative is FREE and it comes with Windows by default.

If you are using Windows 7, Windows Server 2012 or later version, it has a free inbuilt Task Scheduler. I have used this multiple times with my customer who are using SQL Server Express and it has worked brilliantly every single time. Here is the tutorial for Task Scheduler.

SQL SERVER - Express and SQL Server Agent - Free Alternative task-scheduler-800x509

There are quite a few free alternatives are available on CodePlex but I have found Task Scheduler very reliable. Give it a go if you are using SQL Server Express and need some of the functionality of SQL Server Agent.

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

First appeared on SQL SERVER – Express and SQL Server Agent – Free Alternative

SQL SERVER – Error 33222, Level 16 – Audit ‘MyAudit’ Failed to Start

$
0
0

SQL SERVER - Error 33222, Level 16 - Audit 'MyAudit' Failed to Start crosserror-800x800 My learning is always fun. I strongly believe that unless you break something, you can’t learn how to fix them. While writing a new blog about auditing, I faced an interesting error. So, I thought of writing my findings before I write the actual blog. Let us learn about Audit failed to start Error 33222.

Here were the commands I was trying to run.

USE MASTER
GO
-- Create the server audit
CREATE SERVER AUDIT MyAudit
TO FILE (FILEPATH ='E:\Program Files\Microsoft SQL Server\MSSQL13.SQL2016\MSSQL\Audit');
GO
-- Enable the server audit
ALTER SERVER AUDIT MyAudit
WITH (STATE = ON);
GO

It’s a SQL Server 2016 instance and I created a folder called “Audit” in the default MSSQL directory. As soon as I executed second command, I got an error.

Msg 33222, Level 16, State 1, Line 8
Audit ‘MyAudit’ failed to start . For more information, see the SQL Server error log. You can also query sys.dm_os_ring_buffers where ring_buffer_type = ‘RING_BUFFER_XE_LOG’.

The thing I like about the error message is that it tells me what I need to do next. If you are new to SQL Server and don’t know about ERRORLOG, then follow below blog.

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

Here

2017-03-07 05:20:53.36 spid54 Audit: Server Audit: 65537, State changed from: TARGET_CREATION_FAILED to: SHUTTING_DOWN
2017-03-07 05:20:53.36 spid54 Audit: Server Audit: 65537 Session has been closed
2017-03-07 05:20:53.36 spid54 Audit: Server Audit: 65537, Initialized and Assigned State: START_FAILED
2017-03-07 05:20:53.36 spid54 Audit: Server Audit: 65537, State changed from: START_FAILED to: TARGET_CREATION_FAILED
2017-03-07 05:20:53.36 spid54 Error: 33206, Severity: 17, State: 1.
2017-03-07 05:20:53.36 spid54 SQL Server Audit failed to create the audit file ‘E:\Program Files\Microsoft SQL Server\MSSQL13.SQL2016\MSSQL\Audit\MyAudit_F141FF1E-8041-48E9-BC2E-27FA3BA90213_0_131333178533700000.sqlaudit’. Make sure that the disk is not full and that the SQL Server service account has the required permissions to create and write to the file.
2017-03-07 05:20:53.37 spid54 Error: 33244, Severity: 17, State: 1.
2017-03-07 05:20:53.37 spid54 SQL Server Audit failed to create an audit file related to the audit ‘MyAudit’ in the directory ‘E:\Program Files\Microsoft SQL Server\MSSQL13.SQL2016\MSSQL\Audit’. Make sure that the disk is not full and that the SQL Server service account has the required permissions to create and write to the file.
2017-03-07 05:20:53.37 spid54 Audit: Server Audit: 65537, Initialized and Assigned State: TARGET_CREATION_FAILED

So, the message was very clear that service account needs permission to write to that folder. I also check ring buffer using query

SELECT *
FROM sys.dm_os_ring_buffers
WHERE ring_buffer_type = 'RING_BUFFER_XE_LOG'

and found below.

Error code 5 is access denied which is matching with ERRORLOG message.

SOLUTION/WORKAROUND

  1. Make a note of service account of SQL Server service using configuration manager.
  2. Provide full control to the folder where we want to write audit file. In my example, it was ‘E:\Program Files\Microsoft SQL Server\MSSQL13.SQL2016\MSSQL\Audit’. This can be done by Right click on the folder, going to properties, then security and adding service account there.

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

First appeared on SQL SERVER – Error 33222, Level 16 – Audit ‘MyAudit’ Failed to Start

SQL SERVER – System. Security. Cryptography. CryptographicException – There Was an Error Generating the XML Document

$
0
0

SQL SERVER - System. Security. Cryptography. CryptographicException - There Was an Error Generating the XML Document xml One of my clients contacted me in assistance to install SQL Server. Generally, this is straightforward, but sometimes there are problems. This time we received an error message and it was very interesting. Let us learn about error related to the XML Document.

SQL Server Setup has encountered the following error:
There was an error generating the XML document.
Error code 0x84B10001.

When we searched on the internet, we were asked to see more details in setup logs. In Summay.txt we were seeing below the messages.

HResult : 0x80090345
Stack:
at System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope scope)
at Microsoft.SqlServer.Common.SqlSecureString.WriteXml(XmlWriter writer)

If we look at the start place of the error, it says System.Security.Cryptography.CryptographicException. This means that there are some issues while encryption of the data. And the real error message is “The requested operation cannot be completed. The computer must be trusted for delegation and the current user account must be configured to allow delegation.”

When I searched with above two, then I found that this can happen when there is Read Only Domain Controller (RODC).

WORKAROUND/SOLUTION

To solve this, we created the registry entry DWORD Protection Policy and set to 1 to enable local backup of the MasterKey instead of requiring a RWDC in the following registry subkey:

HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Protect\Providers\df9d8cd0-1501-11d1-8c7a-00c04fc297eb

Setting this value to 1 causes DPAPI master keys to be backed up locally rather than using a domain backup. For more information about DPAPI you can read https://support.microsoft.com/en-us/kb/309408

This workaround is documented in https://support.microsoft.com/en-in/help/3000850/november-2014-update-rollup-for-windows-rt-8.1,-windows-8.1,-and-windows-server-2012-r2

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

First appeared on SQL SERVER – System. Security. Cryptography. CryptographicException – There Was an Error Generating the XML Document

SQL SERVER – Msg 3101, Level 16 – Exclusive Access Could not be Obtained Because the Database is in Use

$
0
0

This error might have seen by DBAs and they know how to fix it. This blog goes in little details about what are the various options available. Here is the simple reproduction of the error message related to exclusive access.

SQL SERVER - Msg 3101, Level 16 - Exclusive Access Could not be Obtained Because the Database is in Use restore-in-use-01-800x324

USE master
GO
CREATE DATABASE SQLAuthority
GO
BACKUP DATABASE SQLAuthority TO DISK = 'SQLAuth.bak'
GO
-- at this point open another query window and connect to SQLAuthority
RESTORE DATABASE SQLAuthority FROM DISK = 'SQLAuth.bak'
GO

Here are the few things which we can check.

  1. Use sys.dm_exec_sessions to identify who is using the database which we are restoring.
SELECT session_id
	,host_name
	,program_name
	,client_interface_name
	,login_name
	,STATUS
	,is_user_process
FROM sys.dm_exec_sessions
WHERE database_id = db_id('SQLAuthority')
  1. The database that we are trying to restore should not be set as the default database for the login that we are using. We can verify the default database for a login by running the query-
SELECT loginname
	,dbname
FROM sys.syslogins
WHERE dbname = 'SQLAuthority'
  1. If you want, you can take the database offline, which would drop all the connection. Then you can perform restore.
  2. We can also detach the database. By detaching, the data and transaction log files of the database will be available on the same location. If we have to restore the same database at same files when we need to delete the files.
  3. Another option would be to drop the database. Once dropped, its files and data are deleted from the disk on the server. When a database is dropped, it is permanently removed and cannot be retrieved without using a previous backup.

Which is the most common option you use to refresh development/QA server from production server?

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

First appeared on SQL SERVER – Msg 3101, Level 16 – Exclusive Access Could not be Obtained Because the Database is in Use


SQL SERVER – Msg 3136, Level 16 – This Differential Backup Cannot be Restored Because the Database has not Been Restored to the Correct Earlier State

$
0
0

I was trying to teach copy-only backups to my students and encountered below error related to differential backup.

Msg 3136, Level 16, State 1, Line 28
This differential backup cannot be restored because the database has not been restored to correct the earlier state.
Msg 3013, Level 16, State 1, Line 28
RESTORE DATABASE is terminating abnormally.

I have written a blog earlier in the same error message.

SQL SERVER – FIX: ERROR : Msg 3136, Level 16, State 1 – This differential backup cannot be restored because the database has not been restored to correct the earlier state

Here are the steps to create the scenario

USE master
GO
CREATE DATABASE SQLAuthority
GO
BACKUP DATABASE SQLAuthority TO DISK = 'SQLAuth_Full_01.bak' WITH FORMAT
GO
BACKUP DATABASE SQLAuthority TO DISK = 'SQLAuth_Diff_01.bak' WITH DIFFERENTIAL, FORMAT
GO
BACKUP DATABASE SQLAuthority TO DISK = 'SQLAuth_Full_02_cp.bak' WITH COPY_ONLY, FORMAT
GO
BACKUP DATABASE SQLAuthority TO DISK = 'SQLAuth_Diff_02.bak' WITH DIFFERENTIAL, FORMAT
GO

SQL SERVER - Msg 3136, Level 16 - This Differential Backup Cannot be Restored Because the Database has not Been Restored to the Correct Earlier State restore-error-diff-01

The above image shows the series of backup I have taken. You can read more about COPY_ONLY backup in books online. The error would come if I restore Diff_02 on top of Full_02_cp. Below is the code to reproduce the error.

USE [master]
RESTORE DATABASE [SQLAuthority_1] FROM
DISK = N'SQLAuth_Full_02_cp.bak'
WITH  FILE = 1,
MOVE N'SQLAuthority' TO N'G:\SQL_FILES\SQLAuthority_1.mdf',
MOVE N'SQLAuthority_log' TO N'G:\SQL_FILES\SQLAuthority_1_log.ldf',
NOUNLOAD,  STATS = 5, NORECOVERY
GO
RESTORE DATABASE [SQLAuthority_1]
FROM  DISK = N'SQLAuth_Diff_02.bak' WITH  FILE = 1,
RECOVERY,  NOUNLOAD,  STATS = 10
GO

SOLUTION/WORKAROUND

We need to restore a differential backup on top of regular full backup, not copy_only full backup. Following command would work as we are restoring diff_02 after performing restore of Full_01.

DROP DATABASE [SQLAuthority_1]
GO
USE [master]
RESTORE DATABASE [SQLAuthority_1] FROM
DISK = N'SQLAuth_Full_01.bak'
WITH
MOVE N'SQLAuthority' TO N'G:\SQL_FILES\SQLAuthority_1.mdf',
MOVE N'SQLAuthority_log' TO N'G:\SQL_FILES\SQLAuthority_1_log.ldf',
NOUNLOAD,  STATS = 5, NORECOVERY
GO
RESTORE DATABASE [SQLAuthority_1]
FROM  DISK = N'G:\SQL_FILES\SQLAuth_Diff_02.bak'
WITH RECOVERY,  NOUNLOAD,  STATS = 10
GO

Have you ever encountered such issues during disaster recovery where chain is broken?

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

First appeared on SQL SERVER – Msg 3136, Level 16 – This Differential Backup Cannot be Restored Because the Database has not Been Restored to the Correct Earlier State

SQL SERVER – Script to Audit Login and Role Member Change

$
0
0

SQL SERVER - Script to Audit Login and Role Member Change dbaudit Once there was a security breach on my client machine and they wanted to know who made changes to the SysAdmin role. They contacted me and my first question was that, are you are auditing such changes and as expected answer was No. I gave them answer that nothing can be done as a consultant. They still wanted my suggestion to prevent this in future. So, they want to track if someone does such things in future. Let us see a script to audit login and role member change.

Here is the solution I provided them and here I am sharing with everyone. I provided them script to create Audit and added those events which are useful to trace such issues. Creating a new Login, Adding a Login to a role would be tracked using below.

WORKAROUND/SOLUTION

USE MASTER
GO
-- Create the server audit
CREATE SERVER AUDIT login_perm_audit
TO FILE ( FILEPATH ='E:\DATA\' );
GO
-- Enable the server audit
ALTER SERVER AUDIT login_perm_audit
WITH (STATE = ON) ;
GO
CREATE SERVER AUDIT SPECIFICATION login_audit_spec
FOR SERVER AUDIT login_perm_audit
ADD (SERVER_PERMISSION_CHANGE_GROUP),
ADD (SERVER_PRINCIPAL_CHANGE_GROUP),
ADD (SERVER_ROLE_MEMBER_CHANGE_GROUP)
WITH ( STATE =  ON )

TESTING

To test the audit defined above, we create a new login and added that login to SysAdmin role

USE [master]
GO
CREATE LOGIN [HackerLogin] WITH PASSWORD=N'P@$$@w0rd123', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
ALTER SERVER ROLE [sysadmin] ADD MEMBER [HackerLogin]
GO

And here is what we see in Audit logs.

Date 04-Apr-17 3:49:36 AM
Log Audit Collection (login_perm_audit)
Event Time 03:49:36.6885017
Server Instance Name SQLAUTHORITY\SQL2016
Action ID CREATE
Class Type SQL LOGIN
Server Principal Name sa
Database Name master
Object Name HackerLogin
Statement CREATE LOGIN

 

Date 04-Apr-17 3:49:39 AM
Log Audit Collection (login_perm_audit)
Event Time 03:49:39.0882101
Server Instance Name SQLAUTHORITY\SQL2016
Action ID ADD MEMBER
Class Type SERVER ROLE
Server Principal Name sa
Target Server Principal Name HackerLogin
Object Name sysadmin
Statement ALTER SERVER ROLE [sysadmin] ADD MEMBER [HackerLogin]

This fulfilled their request and they could find the process which was doing it.

Do you use Audit in a production environment? If yes, is it a native SQL audit or some 3rd party solution?

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

First appeared on SQL SERVER – Script to Audit Login and Role Member Change

SQL SERVER – Unable to recycle Errorlog – sp_cycle_errorlog – OS error 1392

$
0
0

One of my clients contacted me and informed that they have a node production clustered server and they recently noticed that the nightly error log had stopped cycling ERRORLOGs. When we attempted to run sp_cycle_errorlog we get the following:

Msg 17049, Level 16, State 1, Procedure sp_cycle_errorlog, Line 9
Unable to cycle error log file from ‘G:\SQL_DATAMNT\MSSQL13.MSSQLSERVER\MSSQL\Log\ERRORLOG.10’ to ‘G:\SQL_DATAMNT\MSSQL13.MSSQLSERVER\MSSQL\Log\ERRORLOG.11’ due to OS error ‘1392(failed to retrieve text for this error. Reason: 15105)’. A process outside of SQL Server may be preventing SQL Server from reading the files. As a result, errorlog entries may be lost and it may not be possible to view some SQL Server errorlogs. Make sure no other processes have locked the file with write-only access.”
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

Above error has one meaningful information which is not very clearly visible. OS Error 1392. What does it mean?

SQL SERVER - Unable to recycle Errorlog - sp_cycle_errorlog - OS  error 1392 sp_cycle-err-01

As shown above, the error means – The file or directory is corrupted and unreadable.

When we try opening ERRORLOG.10 we got exactly the same error. What is the solution now?

WHY ERROR?

When SQL Server recycles the ERRORLOG, it will rename all the previous ERRORLOG.n to ERRORLOG.(n+1), and then create a new ERRORLOG as the most current one. If the rename process fails, the recycle of ERRORLOG cannot complete.

WORKAROUN/SOLUTION

Since we can’t use that file and in this case even deletion of the file was also not happening. We changed -e parameter in configuration manager to use the new path.

SQL SERVER - Unable to recycle Errorlog - sp_cycle_errorlog - OS  error 1392 sp_cycle-err-02

Then we failed over the SQL cluster instance to another node. We verified that the SQL server can come online and ERRORLOG generated at the new location. Then we can recycle command again and it worked!

CONCLUSION

Note that this is a serious error. I told my client that he was lucky that it happened with ERRORLOG file. Imagine if it happens with database related MDF or LDF file. They immediately engaged a hardware vendor for the disk sanity check.

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

First appeared on SQL SERVER – Unable to recycle Errorlog – sp_cycle_errorlog – OS error 1392

SQL SERVER – Unable to Install Service Pack in Cluster – There was an Error to Lookup Cluster Resource Types

$
0
0

SQL SERVER - Unable to Install Service Pack in Cluster - There was an Error to Lookup Cluster Resource Types SQL-Cluster Learning never stops for me with SQL Server. Even though I have written articles to solve many issues, I still get pinged from various clients and I find one new thing every day. In this blog post we will learn how to fix the error related to installing the service pack in the cluster.

The other day, while my client was trying to apply service pack for SQL Server and it was failing with an error. When I asked them to share the Detail.txt, I could find below exception which was causing failures.

The following is an exception stack listing the exceptions in outermost to innermost order

Inner exceptions are being indented

ErrorType = 2
Operation = GetObject
ParameterInfo = MSCluster_ResourceType.Name=”Double-Take Source Connection”
ProviderName = MS_CLUSTER_PROVIDER
StatusCode = 4104
Stack:

When I searched on the internet, I found that this was caused to another person in the world due to “Double-Take Source Connection”. We can also see that in our stack.

WORKAROUND/SOLUTION

I gave the option to the customer to contact either Microsoft or Double take software vendor to find the cause of the issue. But they informed that they are not using double-take and it was installed for testing purpose. There was no resource of double-take in their cluster.

Since they were OK to get rid of double-take, we ran below command.

Remove-ClusterResourceType -name “Double-Take Source Connection”

This deleted the “Double-Take Source Connection” cluster resource type, now it was no longer listed using below command

Get-ClusterResourceType

Once we removed above resource type, they were able to install the service pack successfully.

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

First appeared on SQL SERVER – Unable to Install Service Pack in Cluster – There was an Error to Lookup Cluster Resource Types

SQL SERVER – FIX: Error: 913, Severity: 16 – Could Not Find Database ID 3. Database May Not be Activated Yet or May be in Transition – SQL Service

$
0
0

This blog is a result of a Skype conversation with one of my clients. The issue, for which they contacted me, was that they were not able to stat SQL Service due to database may not be activated. I asked to share SQL Server ERRORLOG files using below blog SQL SERVER – Where is ERRORLOG? Various Ways to Find ERRORLOG Location

SQL SERVER - FIX: Error: 913, Severity: 16 - Could Not Find Database ID 3. Database May Not be Activated Yet or May be in Transition - SQL Service error-red

Here is the information which I saw.

2017-04-02 16:38:02.40 spid11s Error: 913, Severity: 16, State: 6.
2017-04-02 16:38:02.40 spid11s Could not find database ID 3. Database may not be activated yet or may be in transition. Reissue the query once the database is available. If you do not think this error is due to a database that is transitioning its state and this error continues to occur, contact your primary support provider. Please have available for review the Microsoft SQL Server error log and any additional information relevant to the circumstances when the error occurred.

The above message is scary because it says that it can’t fine Database ID = 3. If you look at documentation, it is the ID for model database. We know that model is a system database which is needed for SQL to start and any issues with this database would cause SQL startup failures. In my case, the client didn’t know how it was detached. Now, the next step is what we should do?  There were NO backups available. We had MDF and LDF files. So, I tried below.

Solution / Workaround:

  • I started the SQL Instance using trace flag 3608, which is documented in books online. Then we tried to attach the model database and got the below error:

Create Database failed
Error: 33401, Severity: 16, FILESTREAM database options cannot be set on system databases such as model.

  • We tried picking model database files from different servers, but no luck.
  • Since there was no backup, we were not able to try to restore.

Finally, I have asked them to rebuild the system databases by keeping the copy of MDF and LDF files for all databases as a backup.

Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS=”BUILTIN\Administrators” /SAPWD= AVeryStrongP@$$word123 /SQLCOLLATION= “SQL_Latin1_General_CP1_CI_AS”

Once above command was finished, it was as good as fresh install of SQL Server. Later we attached all user databases and created all system objects.

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

First appeared on SQL SERVER – FIX: Error: 913, Severity: 16 – Could Not Find Database ID 3. Database May Not be Activated Yet or May be in Transition – SQL Service

Viewing all 594 articles
Browse latest View live