Posted in Development, Performance Tuning

How to collected inventory for SQL Server using Microsoft Assessment and Planning (MAP) tool

Hi friends,

We need to collect inventory for database migration as well as platform to set up environment for migration, development and testing.

Is there any tool from Microsoft to achieve this scenario?

Yes, we have Microsoft Assessment and Planning Tool (MAP) for it.

From BOL:

The Microsoft Assessment and Planning (MAP) Toolkit is an inventory, assessment, and reporting tool that helps you assess your current IT infrastructure and determine the right Microsoft technologies for your IT needs. The MAP toolkit uses Windows Management Instrumentation (WMI), Active Directory Domain Services (AD DS), SMS Provider, and other technologies to collect data in your environment and inventories computer hardware, software, and operating systems in small or large IT environments without installing any agent software on the target computers.

In order for the MAP Toolkit to successfully connect and inventory computers in your environment, you have to configure your machines through WMI and also allow your firewall to enable remote access through WMI. In addition to enabling WMI, you need accounts with administrative privileges to access desktops and servers in your environment.

Download and Install MAP tool

You can download Microsoft Assessment and Planning Toolkit from

Once the MAP tool is installed SQL Server LocalDB gets installed by default.

Latest Version of MAP tool is 9.4

MAP 9.4 is updated to inventory, assess and report the SQL Server 2016 instances and components in the SQL Server assessment.

  1. After opening it Create inventory database which will be used to save the inventory data and statistics inside it when working with MAP tool.


2. Once you opened the MAP tool in the Create or Select a Database to Use dialog click Create an inventory database and type student as a new database name and click OK.

Student database is created successfully and message will also appears for this.

3. To enable the remote administration open the Command Prompt as Run As Administrator.

Type the following command and press enter, you will get the message OK in response.

netsh advfirewall set currentprofile settings remotemanagement enable

 4. This is home screen for MAP tool which allow the different options to collect the inventory data for Server, Desktop, Cloud etc.


MAP toolkit uses WMI, Active Directory Domain Services, SQL Server Commands, VMware web services, Oracle client, PowerShell  and SSH with remote shell commands to collect the inventory information from the target network machines. It is not required to have the MAP tool on the target machine to collect the inventory.

5. Click on Database option from left side pane

6. Now click on Collect Inventory Data link, an Inventory and Assessment Wizard window opens.


You can choose the scenarios on your choice to collect the inventory with various scenarios available:

  • Windows-based computers
  • Linux-based computers
  • VMware computers
  • Exchange Server
  • Active Devices and users
  • Forefront Endpoint Protection Server
  • Lync Server
  • SQL Server
  • SQL Server with database details
  • Windows Azure Platform Migration
  • MySQL, Oracle, and Sybase

7. Choose option SQL Server and SQL Server with Database Details as Inventory Scenario.

8. Click Next.

Discovery Methods tab appears which is used to discover computers. Various discovery methods available for selection of method-

  • Active Directory® Domain Services
  • Windows networking protocols
  • System Center Configuration Manager
  • Scan an IP address range
  • Manually enter computer names and credentials
  • Import computer names from a file


9. Select option Manually enter computer names and credentials.

Click Next.

10. Now in All Computer Credentials page, click Create.

11. In the Account Entry dialog, type the username for the local computer user

12. In both the Password and Confirm Password fields, type the password for the local computer user then click Save

13. In the All Computer Credentials Page, click

14. Click Next in the Credentials Order

15. In the Enter Computers Manually page, click Next.

16. Now, in Specify computers and credentials page enter your computer name and Click on Add.

You can add multiple computer names here as per your requirement.

17. Click on Save


18. Then Clicking on Next button will take you on Summary section.

19. In Summary section you can see the summary of your selection including any detected errors.

620. Click on Finish

21. Inventory and Assessment Windows appears on screen where you can see the progress of Data collection.


How to generate reports to get SQL Server DB information?

 To generate the report, we will click on SQL Server from Database scenario.

In the option section two types of reports can be generated:

  1. Generate SQL Server Assessment Report
  2. Generate SQL Server Database Detail Report

Click on any report and save to your local disk.


These two reports shows different type of information which are like –

  1. SQL Server Assessment Report

This report shows information about Database Instances and Components.

2. SQL Server Database Detail Report

This report provides an information of all the SQL Server database engine instances and number of databases discovered on your network.

So, in this way we can use MAP tool to collect the inventory and statistics.

Posted in Performance Tuning, Uncategorized

SQL Server Execution Plan Operator – Table Scan

In my previous blog we discussed about the different format of SQL Server execution plan. Now in upcoming blogs we will discussed about the most commonly seen operators we see when execution plan generates. In this post I will start the easy one that is Table Scan operator.

As with the name of operator Table Scan it indicates that it returns the rows after scanning every row of a table.

When this operator appears in execution plan?

When there is no index present on the table then query optimizer has to scan every row of table to return the result set.


In the returned result set data is retrieved after traversing data row by row.

When a table is having fewer rows and returning maximum rows then it’s faster for query optimizer to scan all rows rather than checking indexes.

That’s all for the day !!!


Posted in Development, Performance Tuning, Uncategorized

SQL Server Execution Plan formats

Execution plan helps in knowing how a query gets executed and troubleshooting a query which is performing poor.

In SQL Server execution plan can be of 2 types:

  1. Estimated Execution plan
  2. Actual Execution plan

Execution plan can be viewed in 3 different formats:

  • Text format
  • XML format
  • Graphical format

We can choose the format on depending what level of details we want to see.

Let’s discuss these format one by one.

  1. Text format

Execution plan in text format can be seen using these 3 methods.

  • Showplan_ALL
  • Showplan_Text
  • Statistics Profile

Showplan_ALL : Its shows the estimated execution plan of the query. To enable it we need to execute the query:



Once we analyze our query plan we can turn off this option by executing below query so that our subsequent queries will not get affected from this.


Showplan_Text: It’s also works with the estimated execution plan of the query. To enable it we need to execute the query:




Statistics Profile: It works with the actual execution plan. We need to execute the below query to enable it:




2 XML format plans

Execution plan can be seen in XML format by using following two methods:

Showplan XML

Statistics XML

Statistics XML: It is used to generate the execution plan in XML format. After clicking on XML link a graphical execution plan gets opened in a new window. We can save that graphical plan to our local disk with extension .sqlplan.


Showplan XML: It’s also generates the XML plan and only one result set appears in outcome with XML link.


3. Graphical Plan

This is the most easiest and readable option to generate the execution plan. It also has two option for generating execution plan:

Estimated execution plan

Actual execution plan

To enable the estimated execution plan we can press the shortcut key Ctrl +L. Also, we can navigate to Query tab and select Display Estimated Execution Plan.

Estimated execution plan is beneficial when we have complex query and not aware how much it will take for complete execution in such situation we can use this as this doesn’t execute the query to generate the plan.


Similarly, actual execution plan we can be enabled by using shortcut key Ctrl+M.

We can also activate it by selecting option Include Actual Execution Plan from Query menu tab.

That’s all for the day folks.


Posted in Development

Limitation of In-Memory OLTP in SQL Server 2016 – Sp_rename not allowed

Hi friends, one more limitation of In-Memory OLTP is SQL Server 2016 is that sp_rename is not allowed to change the name of in-memory OLTP objects.

Sp_rename is a system stored procedure which allows to change the name of the user-defined objects like table name, column name, datatype of a column etc. in the current database.

Let’s see an example of this –

There is already an In-memory table created with name ‘Test_OLTP’ and now I like to rename it with a new name ‘MemOLTP’.

I have executed the below query to rename the table name.

sp_rename ‘dbo.Test_OLTP’,’MemOLTP’

When I executed the query it comes up with an error stating –

‘Operations that require a change to the schema version,

for example renaming, are not supported with memory optimized tables.’


That’s all for the day folks 🙂


Posted in Development

Getting started with In Memory OLTP in SQL Server 2016 – Part 1

In Memory OLTP (Hekaton) introduced in SQL Server 2014 is a new database engine component which is optimized for OLTP workloads to achieve the performance by storing data in memory and accessing data from memory. Memory optimized tables can be accessed using Transact –SQL. When memory optimized tables are accessed all data is stored into the memory.

Today, I will tell you how to create a memory optimized tables.

Let’s first create a database to stored memory optimized tables. Database that contain memory optimized tables must have MEMORY_OPTIMIZED_DATA filegroup. Syntax to create filegroup is same as creating regular filegroup only difference is that here we need to specify option CONTAINS MEMORY_OPTIMIZED_DATA.

–Create a database

IF EXISTS (SELECT * FROM sys.databases WHERE name=’InMemOLTP’)






FILENAME = ‘I:\453491\InMemOLTP\Data\HKDB_data.mdf’, size=500MB),


(NAME = [InMemOLTP_mod_dir],

FILENAME = ‘I:\453491\InMemOLTP\InMemOLTP_mod_dir’)

LOG ON (name = [InMemOLTP_log],

Filename=’I:\453491\InMemOLTP\Log\InMemOLTP_log.ldf’, size=500MB)

COLLATE Latin1_General_100_BIN2;

Here, I have created a filegroup ‘InMemOLTP_fg’ with filecontainer ‘InMemOLTP_mod_dir’. I have also specifies BIN2 collation as currently indexes on character column can only be defined on columns that uses BIN2 collation.

Below is the script to create a memory optimized table with name ‘Test_OLTP’.




       Place varchar(30),

       CompanyName varchar(40),

       Skill varchar(100)


Syntax to create memory optimized table is similar to the Transact SQL tables but to specify a memory optimized table we need to define clause MEMORY_OPTIMIZED = ON. Memory optimized table can be defined using two durability – SCHEMA_AND_DATA and SCHEMA_ONLY.

With SCHEMA_ONLY durability, memory optimized table will store only table structure and SQL server will not store log changes to the disk. With SCHEMA_AND_DATA, memory optimized table store table data to the checkpoint files on disk and table structure too.

Nonclustered Hash index is created on Name column as clustered indexes are not allowed on memory optimized tables. If you don’t specify Nonclustered with Primary Key column you will get error –

Msg 12317, Level 16, State 78, Line 21

Clustered indexes, which are the default for primary keys, are not supported with hash indexes. Specify a NONCLUSTERED index instead.

When we create a HASH index we need to specify the number of buckets in the hash index. More on Bucket_count I will discuss later in further posts.

Now, the table has been created, let’s try to insert some data into memory optimized table.

INSERT INTO Test_OLTP (Name, Place, CompanyName, Skill)

VALUES (‘Kapil’, ‘Gurgaon’,’CTS’,’SQL Server’),


Just check the data that you has inserted by running below query.



So friends, in this way we can create memory optimized database and table. We will discuss further on memory optimized tables in my next blogs.

Have a happy learning 🙂

Posted in Development

Limitation of In-Memory OLTP in SQL 2016 – Create Index is not supported

Hi friends, in this blog I will discuss another limitation of In Memory OLTP in SQL Server 2016.

Once you create a table you cannot create any index created on memory optimized table using CREATE INDEX statement. So to create indexes you need to create them with column definition of memory optimized table.

Let’s create a memory optimized table with index on column Name.




       Place varchar(30),

       CompanyName varchar(40),

       Skill varchar(100)


After creation of the table I also want to create a nonclustered index on column ‘CompanyName’.

Let’s execute the below query to create a nonclustered index-

Create nonclustered index ix_companyname ON Test_OLTP(CompanyName)

When I run this query I got an error –

Msg 10794, Level 16, State 13, Line 4

The operation ‘CREATE INDEX’ is not supported with memory optimized tables.


So, we cannot alter the memory optimized tables once created as SQL Server stores the structure of memory optimized tables as metadata.

To alter the table either recreate the table or create another table.

That’s all for the day 🙂

Have a nice day!!