Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Finding Dependencies of Objects Expand / Collapse
Author
Message
Posted Friday, December 27, 2013 12:28 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, October 13, 2014 4:33 AM
Points: 141, Visits: 403
Hi There,

I need to do some clean up activities in my databases... So i intended to drop unwanted tables and views.

for that I need to find, whether the table being used by any other objects ?

How could I achieve it?

thanks in advance
Post #1526095
Posted Friday, December 27, 2013 5:46 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 1:11 PM
Points: 12,905, Visits: 32,161
procs and views referencing your tables are only part of the puzzle;
applications can have dependencies on those tables, and applications can reference tables that are never used.

there's a handy chartabout how 45% of application improvements get added but are never used, and those improvements most likely reference objects int ehd atabase which need to exist, but are never used as well.

you'll need to search applcation code in addition to the database.



here's a handy script for you for the SQL side:
SELECT 
depz.referenced_schema_name,
depz.referenced_entity_name,
objz.type_desc,
object_schema_name(depz.referencing_id) As ReferencingSchema,
object_name(depz.referencing_id) AS ReferencingObject,
colz.name AS ColumnName
FROM sys.sql_expression_dependencies depz
INNER JOIN sys.objects objz ON depz.referenced_id=objz.object_id
LEFT OUTER JOIN sys.columns colz ON objz.object_id = colz.object_id
AND colz.column_id = referencing_minor_id
--WHERE referencing_id = OBJECT_ID(N'MyTable');
WHERE referenced_id = OBJECT_ID(N'EDLogDetail');
--AND colz.name = 'EmployeeNumber'



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1526113
Posted Friday, December 27, 2013 12:50 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, February 7, 2014 4:39 AM
Points: 20, Visits: 77
As far as identifying application dependencies go, one technique is to run SQL server profiler while the application is being used (It's resource intensive, so ideally you'd want to run this in a test environment). If feasible, you can perhaps have someone run through all the major functions in a test environment, while profiler is running. Then inspect the traces to identify all the objects which the application uses. I can provide more details if you need.
Post #1526245
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse