In sql server how difficult would it be to determine what procedures/functions no longer compile? In other words, if I scripted out alter statements for all procedures and functions in a database, I’d like to know which of these statements are going to fail?
I’ve been working on cleaning up a database I’ve inherited which has gone through years of changes and I’d like to what objects are going to raise errors when something tries to execute it.
Try this
Call sp_refreshsqlmodule on all non-schema bound stored procedures:
This works for all views, functions and SPs. Schemabound objects won’t have problems and this can’t be run on them, that’s why they are excluded.
Note that it is still possible for SPs to fail at runtime due to missing tables – this is equivalent to attempting to ALTER the procedure.
Note also that just like ALTER, it will lose extended properties on UDFs – I script these off and restore them afterwards.