sql server - How do you find all dependencies of a database table? -


In MS SQL 2005 it is possible to find out which tables / columns are used as keys in other keys Are they being done, or as part of a stored procedure?

The reason for this is that I am trying to clean up some old stored processes and tables, some of which can be removed, some of which can be harvested. But obviously I do not want to remove those things that are being used.

  announcement @ base object Varchar (100) SET @BaseObject = 'AddEntry' SET on DECLARE NOCOUNT @ Object Table INSERT @ Objects (ID) from SYSObjects SELECT id where @BaseObject WHILE (@@ ROWCOUNT & gt; 0) BEGIN INSERT @Objects (ID) SELECT d.depid to sysdepends d WHERE d.id IN (Object from SELECT id) and not d.depid (SELECT id FROM @Objects) END SET NOCOUNT OFF SELECT Convert (varchar (100), '[' + oo.name + ']. [' + '+ O.name +'] ') AS' --Object-- 'sysobjects to connect o iner sysusers oo ON o.uid = oo.uid WHERE o.id IN (objects with SELECT id) ORDER BY oo.name, o.name  

Comments