• Thanks for the post! I realize this post is pretty old now, but in case it helps the next person through....

    • The view refresh fails for schema bound views. Add WHERE OBJECTPROPERTY(v.object_id, 'IsSchemaBound') = 0 to the cursor that finds views
    • If you make this into an SP yourself, you'll need to add commit transactions in the try blocks otherwise and either exclude this SP from being checked or update the find/replace part to only do it on the first CREATE PROCEDURE/FUNCTION otherwise it will change the innards of the SP and it won't work the 2nd time around.