Create missing index on a table on SSMS 2008 and above

Costas

Administrator
Staff member
nefSLlx.png


or

YIlctRL.png


execute your query
JavaScript:
USE AdventureWorks 
GO

SELECT CustomerID, Name, SalesPersonID, ModifiedDate 
FROM Sales.Store 
WHERE (Name='Bike World' AND ModifiedDate > '2004-10-01')
GO

If dbase needs an INDEX, will appear this 'Missing Index' green line.

65A7Q8A.png


Right click > Missing Index Details
9IJuIFY.png


This will generate T-SQL code for the missing index (SQL Server 2008 Management Studio).
JavaScript:
USE [AdventureWorks]
GO

CREATE NONCLUSTERED INDEX []
ON [Sales].[Store] ([Name],[ModifiedDate])

GO

name the INDEX name
JavaScript:
CREATE NONCLUSTERED INDEX [IDX_Store_Mod_Date]


#create #index #missing

src - https://www.mssqltips.com/sqlservertip/1945/missing-index-feature-of-sql-server-2008-management-studio/
 
Top