Reputation: 465
Having a database with a main table called "MasterTable". Found out that there are some columns in MasterTable that are no longer reasonable (from business purpose). To make everything slimer and easier I'd like to delete those columns.
In case I delete column ABC a view that refers to that column or a stored procedure doing an insert/update might fail when ABC is missing.
For this I'd like to query my database to see all views/procedures that somehow use ABC, before deleting it.
Upvotes: 2
Views: 1053
Reputation: 585
Something like this should help you . But please remember:
It will also give you results where the column might be commented out..
If you use select * in view or procedure it will not be shown in the result
SELECT OBJECT_NAME(OBJECT_ID),definition
FROM sys.sql_modules
WHERE definition LIKE '%' + 'YourColumnName' + '%'
Upvotes: 2