Want to remove an obsolete table column but don’t want to break any views that may still reference it?
SELECT v.NAME, c.[text] FROM syscomments c, sys.VIEWS v WHERE v.OBJECT_ID=c.id
AND c.TEXT LIKE ‘%MY FIELD%’
The above is just for the view, this query will give you all the objects (views, stored procedures, functions etc)
SELECT DISTINCT o.name, o.xtype FROM syscomments c INNER JOIN sysobjects o ON c.id=o.id
WHERE c.TEXT LIKE ‘%table or field name%’
(xtype column: P for stored procedures; V for views; FN for functions)
Advertisement