How to check all stored procedure is ok in sql server if I drop a table or fields?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
I tried "Cade Roux" Answer , it went wrong and I fixed it as following
I found Cade's answer useful in formulating my own script for checking objects in a database, so I thought I'd share my script as well:
Same idea, but more universal - you check all user defined objects with bodies And it shows you error during compiling. This is really useful after renaming/removing objects/columns etc
Just run it after database schema update to make sure that all body objects still valid
Couple of ways that come to mind
It won't catch everything (dynamic SQL or latebound objects), but it can be useful - call sp_refreshsqlmodule on all non-schema bound stored procedures (you can call it before to ensure that dependencies are updated and then query the dependencies, or call it afterwards and see if anything is broken):
In addition to the script from Michael Petito you can check for issues with late-bound objects in SPs (deferred name resolution) like this: