question

rehaan avatar image
rehaan asked

Schema dependecnies

Hi, I have schema's in my database which i think we are not using them anymore. We have 100's of them in each database. Before dropping them how can i check their dependencies, whether they are associated with any table/user or anything? Any help would be much appreciated
schemadependency-check
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
JohnM avatar image
JohnM answered
You should be able to query that using some of the system tables: SELECT * FROM sys.schemas s LEFT JOIN sys.all_objects ao ON s.schema_id = ao.schema_id INNER JOIN sys.database_principals dp ON s.principal_id = dp.principal_id WHERE ao.schema_ID IS NULL AND dp.type 'R' --roles GO You might have to adjust for your particular environment but this would give you list of schema's that do not have any objects tied to it. Hope that helps!
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks John M
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.