Scan stored procedures source script

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

The above is just for the view, this query will give you all the objects (views, stored procedures, functions etc)

SELECT DISTINCT, o.xtype FROM syscomments c INNER JOIN sysobjects o ON
WHERE c.TEXT LIKE ‘%table or field name%’

(xtype column: P for stored procedures; V for views; FN for functions)

This entry was posted in SQL and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s