Category: Miscellaneous

Performance Dash board and performance Baseline

These two articles were published my Microsoft SQL team and it will help you to create Performance dashboard and performance baseline report.

These reports are really cool and will eliminate your performance monitoring need.

https://blogs.msdn.microsoft.com/sql_server_team/sql-server-performance-dashboard-reports-unleashed-for-enterprise-monitoring/

 https://blogs.msdn.microsoft.com/sql_server_team/sql-server-performance-baselining-reports-unleashed-for-enterprise-monitoring/#comment-2705

Alter database set multi_user not working

I got call from one of my client when I was about to leave office and they said their missing critical databases is not coming into multi_user mode.

I was like it’s going to be very easy to resolve.

I tried to run

Alter database <dbname> with multi_user and got below error.

Msg 1205, Level 13, State 68, Server XXXXXXXXXXX, Line 1
Transaction (Process ID 108) was deadlocked on lock resources with another process
and has been chosen as the deadlock victim. Rerun the transaction.
Msg 5069, Level 16, State 1, Server XXXXXXXXXXX, Line 1
ALTER DATABASE statement failed.

I tried to run –

Alter database <dbname> with multi_user with rollback immediate but again same error.

I looked to extended event for deadlock and it was showing nothing.

I looked into processes running on server and found deadlock is happening on system processes, so I can’t even KILL those processes.

Meanwhile client said they have bring all the application down but again no luck.

Finally, After doing some research I am able to find the solution and the solution is set the priority of your session high by below t-sql and it will allow you to run your query.

SET DEADLOCK_PRIORITY HIGH

go

Alter database <dbname> set multi_user

You can find more information here –

https://docs.microsoft.com/en-us/sql/t-sql/statements/set-deadlock-priority-transact-sql

Note – This work  around also help you to resolve any deadlock issue in short run.

 

NetFx3 error while installing SQL Server 2012

Issue – While Installing SQL Server 2012 on windows 2012 server I have received below error, which indicate .Net 3.5 is not installed on this machine.

In windows server 2012 .Net 3.5 do not install by default as it’s come with .Net 4.5.

1

Let’s learn how to install .Net 3.5 on windows 2012 box.

Go to control Panel –> Select Turn windows  features on or off

2

or go to Server Manager –> Add roles and features

3

It launch  new window –> Next

4

select –> “Role-based or feature based installation” –> Next

6

7

Go –> Next –> Next –> Select “.Net Framework 3.5 Feature” –> Next

8

Select –> Specify an alternate source path

9

Find  windows media directory and go to “Source\sxs” path Mine is installed in D:\ so for me it’s “D:\Source\sxs”

11

Provide directory path and click OK.

12

Click on Install –>

13

It will take few minute and then your installation done.

14

Or you can use below command –

dism /online /enable-feature /featurename:NetFx3 /source:D:\sources\sxs

15

Could not locate file ‘xy_abc_Log’ for database ‘abc’ in sys.database_files.

Problem – I have found VLF size of my database abc is very huge and when i have tried to shrink the file i have received below error –

Could not locate file ‘xy_abc_Log’ for database ‘abc’ in sys.database_files.

Resolution –

While my investigation I have found logical fine name under sys.master_files is different as compare to sys.database_files.

select name from sys.master_files where database_id = db_id(‘abc’)

xy_abc_Data
xy_abc_STAGE_Log

select name from sys.database_files

xy_abc_Data
xy_abc_Log

You will find logical name is different hence you need to update logical file name in sys.master_files table.

use [abc]

go

ALTER DATABASE [abc] MODIFY FILE (NAME=N’xy_abc_Log’, NEWNAME=N’xy_abc_Log’)
GO

How to bypass restart computer error message while installing SQL Patch

If you ever encounter restart computer error message while performing SQL Server patching and you don’t have opportunity\permission to restart your machine.

You can bypass this situation by deleting value from PendingFileRenameOperations key.

Here are the steps which you need to follow –>

  1. To Open Registry Editor. Click Start  ( win + R ) –> Run, input “regedit” and press Enter.
  2. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager, and delete any value in “PendingFileRenameOperations” key.

restart

regedit

rerun.PNG

Microsoft Best Practice Analyzer

Microsoft Best Practice Analyzer –

Best Practices Analyzer (BPA) is a server management tool that is available in Windows Server® 2008 R2. BPA can help administrators reduce best practice violations by scanning one or more roles that are installed on Windows Server 2008 R2, and reporting best practice violations to the administrator. Administrators can filter or exclude results from BPA reports that they do not have to see. Administrators can also perform BPA tasks by using either the Server Manager GUI, or Windows PowerShell cmdlets.

You will find more details in –
https://technet.microsoft.com/en-us/library/dd759260(v=ws.11).aspx

Installation of BPA – SQL 2012

Prerequisite
• PowerShell V2.0
• Microsoft Baseline Configuration Analyzer V2.0
• User should have admin access on server and SQL Server
o Note – You need to add your individual id or else you will get login error after running BCA.

Steps by Step Installation –
Step 1 – Download and Install the Microsoft Baseline Configuration Analyzer v2 (BCA) (follow default download instructions) – This will install to C:\Program Files\Microsoft Baseline Configuration Analyzer
Download link – https://www.microsoft.com/en-us/download/details.aspx?id=16475
Step 2- Install the Microsoft SQL Server 2012 Best Practices Analyzer (SQL BPA) (follow default download instructions) – This will install to C:\Windows\System32\BestPractices\v1.0\Models\SQL2012BPA\
https://www.microsoft.com/en-us/download/details.aspx?id=29302
Note – You will not able to see any icon for (SQL BPA) as it’s only install executables.

p1

Working –
Step 1 – Open Microsoft Baseline Configuration

p2

Note – If you wanted to connect remote computer, click on Connect to Another Computer.

p3

Step 2 – Select “SQL Server 2012 BPA” from drop down.
Step 3 – Go to Enter Parameters and select parameters you wants to select.

p4

Note – If it’s remote server provide server name in Alternate_Server_to_scan (Only server name not instance name), provide instance name in SQL_Server_Instanace_name fields.
Step 4 – Click on “Start Scan”
Step 5 – Analyze your result.

p6

Issues –
I was configuring BPA 2012 in windows 2012, after installing both BCA and SQL BPA, I was not able to see “SQL Server 2012 BPA” in drop down and to resolve the issue I have performed below steps –

p7

1. Navigate to the directory C:\Windows\System32\BestPractices\v1.0\Models and right-click the SQL2012BPA folder and make a copy.
2. Navigate to C:\ProgramData\Microsoft\Microsoft Baseline Configuration Analyzer 2\Models\ and paste the SQL2012BPA folder in this new location.
(Note – ProgramData is hidden folder which you need to see after checking “Hidden Items” in view of your file explorer)
3. Start the BCA with Run As Administrator and you will now see the SQL Server 2012 BPA listed in the “Select a product” dropdown.