Pedantic nitpick. The ; is a statement terminator. It does not begin statements. ;WITH is an abomination that I wish would go away.
PiMané (11/28/2012)
DECLARE @FirstColumnsKeys INT = 2;
WITH IndexInfo AS (
Is this assumption, that the first two columns are what really matters and the other can be joined, valid for foreign keys without indexes?
Maybe. It depends how unique the combinations are (and that goes in general, not for foreign keys).
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability