TSQL SHOWPLAN_ALL Commands

Hi again,

In my job I usually need to work with tsql and every query must have the best performance possible, that’s why I used to use the tool within the sql management studio named Graphical Execution Plans but I never know about the tsql commands needed to do it, but here are:

USE AdventureWorks;
GO
SET SHOWPLAN_ALL ON;
GO
-- First query.
SELECT *
FROM HumanResources.Employee
WHERE NationalIDNumber = '509647174';
GO
-- Second query.
SELECT *
FROM HumanResources.Employee
WHERE NationalIDNumber LIKE '1%';
GO
SET SHOWPLAN_ALL OFF;
GO

This commands will show something like this:

Source: http://msdn.microsoft.com/en-en/library/ms187735.aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: