Category: Miscellaneous

Microsoft Contoso BI Demo Dataset for Retail Industry

    Today, I was working on demo where I wanted to have test dataset for Retail db and after some googing I found MS has it’s own database and here are details –
    The Contoso BI Demo dataset is used to demonstrate DW/BI functionalities across the entire Microsoft Office product family. This dataset includes C-level, sales/marketing, IT, and common finance scenarios for the retail industry and support map integration. In addition, this dataset offers large volumes of transactions from OLTP and well-structured aggregations from OLAP, along with reference and dimension data.
    Steps to restore Contoso BI Demo Database
    You can download from below location –
    2.  After download please run the .exe files and it will ask you to unzip
    3. It will generate ContosoRetailDW.bak file along with Data Dictionary of Contoso BI demo dataset for Retail Industry.xls file
    4. Restore database with below script – you can modify your file


USE [master]
RESTORE DATABASE [ContosoRetailDW] FROM DISK = N’C:\ContosoBIDB\ContosoRetailDW.bak’ WITH FILE = 1, MOVE N’ContosoRetailDW2.0′ TO N’D:\Program Files\Microsoft SQL Server\MSSQL13.SQL2016\MSSQL\DATA\ContosoRetailDW.mdf’, MOVE N’ContosoRetailDW2.0_log’ TO N’D:\Program Files\Microsoft SQL Server\MSSQL13.SQL2016\MSSQL\DATA\ContosoRetailDW.ldf’, NOUNLOAD, STATS = 5




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.

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.



Alter database <dbname> set multi_user

You can find more information here –

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.


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

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


or go to Server Manager –> Add roles and features


It launch  new window –> Next


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



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


Select –> Specify an alternate source path


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


Provide directory path and click OK.


Click on Install –>


It will take few minute and then your installation done.


Or you can use below command –

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


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’)


select name from sys.database_files


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

use [abc]


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

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.




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 –

Installation of BPA – SQL 2012

• 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 –
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\
Note – You will not able to see any icon for (SQL BPA) as it’s only install executables.


Working –
Step 1 – Open Microsoft Baseline Configuration


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


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


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.


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 –


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.