Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Object Dependancies

Author  Topic 

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2008-11-19 : 02:23:31
I need to get all Functions and Views on which no other object depends (objects are still not used anywhere in database)
i used following query

SELECT S.name+'.'+O.name
FROM sys.objects O INNER JOIN sys.schemas S ON O.schema_id=S.schema_id
WHERE object_id NOT IN (SELECT depid FROM sysdepends)
AND type IN ('FN','V')
AND type_desc NOT LIKE 'SYSTEM%'
ORDER BY O.type,S.name,O.name

is there any other query which can give me more effective results so i can delete all my unused objects (function, views) from my database

cvraghu
Posting Yak Master

187 Posts

Posted - 2008-11-19 : 03:48:42
Check whether this works for you ...

SELECT OBJECT_NAME(o.object_id)
FROM sys.objects AS o
WHERE o.type IN ('FN','V')
AND NOT EXISTS (SELECT 'X'
FROM sys.sql_dependencies AS d
WHERE d.referenced_major_id = o.object_id)
Go to Top of Page
   

- Advertisement -