Posts tagged Keys
List of foreign key relationships
03 years ago
in Transact-SQL
Use the query below to produce a list of foreign key relationships:
select f.name AS ReferencingTable, fc.name AS ReferencingColumn,
r.name AS ReferencedTable, rc.name AS ReferencedColumn
from sysreferences s
inner join sysobjects f on s.fkeyid = f.id
inner join sysobjects r on s.rkeyid = [...]
Non-clustered indexes
03 years ago
in General
When creating non-clustered indexes, you should never include the clustered index key fields (commonly used for the primary key) as part of the non-clustered index.
This is because the fields will always be used within queries. There is no need to specify them again.
The only exception to this, [...]