Seeing as a foreign key does not automatically create an index in SQL Server, I want to create an explicit index on every FK field in my database. And I have over 100 tables in the schema…
So, does anyone have a ready packaged script that I could use to detect all FKs and create an index on each?
OK, I worked this out myself – here it is for everyone else’s benefit…
It doesn’t work 100%, such as if you have two FKs on one table to the same primary table, but there are few enough instances of this (in my DB at least) that I could viably correct these by hand.