SQL Server, Analytics, .Net, Machine Learning, R, Python
Mitch Wheat has been working as a professional programmer since 1984, graduating with a honours degree in Mathematics from Warwick University, UK in 1986. He moved to Perth in 1995, having worked in software houses in London and Rotterdam. He has worked in the areas of mining, electronics, research, defence, financial, GIS, telecommunications, engineering, and information management. Mitch has worked mainly with Microsoft technologies (since Windows version 3.0) but has also used UNIX. He holds the following Microsoft certifications: MCPD (Web and Windows) using C# and SQL Server MCITP (Admin and Developer). His preferred development environment is C#, .Net Framework and SQL Server. Mitch has worked as an independent consultant for the last 10 years, and is currently involved with helping teams improve their Software Development Life Cycle. His areas of special interest lie in performance tuning
Thursday, September 15, 2011
TSQL: Generate Missing Foreign Key Indexes
It’s good practice to ensure all foreign key columns are indexed (I’ve often wondered why SQL Server Management Studio doesn’t have a built-in option to perform this). I can’t remember where I saw this code originally (despite trying to search for a reference to it), but it is a useful addition to a TSQL code snippet toolbox:
As is, this script prints out the missing index definitions but does not run them into the database. Simply copy and paste into another SSMS query window and run. (You could also uncomment the execute line, but I prefer to check them before running in).
MSN, Email: mitch døt wheat at gmail.com