09 June 2018

Delete Maintenance Plans

We need to perform the below steps to delete the jobs or maintenance plans in such cases from sysmaintplan_log table or fromsysmaintplan_subplans table .
Step 1: 
Execute the below query to obtain the Maintenance plan name and Id 
SELECT NAME, ID FROM MSDB..SYSMAINTPLAN_PLANS 
Step 2: 
Replace the Id obtained from Step 1 into the below query and delete the entry from log table
DELETE FROM SYSMAINTPLAN_LOG WHERE PLAN_ID=' ' 
Step 3: 
Replace the Id obtained from Step 1 into the below query and delete the entry from subplans table as shown below,
DELETE FROM SYSMAINTPLAN_SUBPLANS WHERE PLAN_ID = ' '
Step 4: 
Finally delete the maintenance plan using the below query where ID is obtained from Step1
DELETE FROM SYSMAINTPLAN_PLANS WHERE ID = ' '
Step 5: 
Check and delete the jobs from SSMS if it exists.

Many thanks to kapil

10 May 2018

Cannot detach a suspect or recovery pending database. It must be repaired or dropped.

Note: Below method of removing database is only when database shows RECOVERY_PENDING because of  MDF/LDF files missing.

Solution:

ALTER DATABASE DBNAME SET OFFLINE
GO
sp_detach_db 'DBNAME'
GO


In Other Cases Please Refer to (Please Note: Check with customer for dataloss)

https://dbamohsin.wordpress.com/2012/01 /23/cannot-detach-a-suspect-or-recovery-pending-database/

Prefer: Use latest backups available to restore the database.

09 February 2018

SSRS Key Mangement Options

C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn>RSKeyMgmt /?
Microsoft (R) Reporting Services Key Manager
Version 11.0.2100.60 x86

Performs key management operations on a local report server.

  -e  extract           Extracts a key from a report server instance
  -a  apply             Applies a key to a report server instance
  -s  reencrypt         Generates a new key and reencrypts all encrypted
                        content
  -d  delete content    Deletes all encrypted content from a report server
                        database
  -l  list              Lists the report servers announced in the report server
                        database
  -r  installation ID   Remove the key for the specified installation ID
  -j  join              Join a remote instance of report server to the
                        scale-out deployment of the local instance
  -i  instance          Server instance to which operation is applied;
                        default is MSSQLSERVER
  -f  file              Full path and file name to read/write key.
  -p  password          Password used to encrypt or decrypt key.
  -m  machine name      Name of the remote machine to join to the
                        scale-out deployment
  -n  instance name     Name of the remote machine instance to join to the
                        scale-out deployment
  -u  user name         User name of an administrator on the machine to join to
                        the scale-out deployment.  If not supplied, the current
                        user is used.
  -v  password          Password of an administrator on the machine to join to
                        the scale-out deployment
  -t  trace             Include trace information in error message

To create a back-up copy of the report server encryption key:
RSKeyMgmt -e [-i <instance name>] -f  -p 

To restore a back-up copy of the report server encryption key:
RSKeyMgmt -a [-i <instance name>] -f  -p 

To reencrypt secure information using a new key:
RSKeyMgmt -s [-i <instance name>]

To reset the report server encryption key and delete all encrypted content:
RSKeyMgmt -d [-i <instance name>]

To list the announced report servers in the report server database:
RSKeyMgmt -l [-i <instance name>]

To remove a specific installation from a scale-out deployment:
RSKeyMgmt -r <installation ID> [-i <instance name>]

To join a remote machine to the same scale-out deployment as the local machine:
RSKeyMgmt -j [-i <local instance name>] -m <remote machine name>
          [-n <remote instance name>] [-u <user name> -v ]

12 January 2018

SQL Server Cluster Uninstall Failed- rule instance removal failed

We recently faced this issue, as the server was migrated to virtual and accidentally windows cluster was removed as part of decommission. Box is left out with SQL Server Installation while uninstalling we hit the below error, once the node name was removed it went successful.




Resolution:

1. Remove the entry from regedit.

HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL11.MSSQLSERVER\Cluster:ClusterName

2. Re-run the uninstall from control panel.