I recently did a rollout in production of a new version of the EHR split over several deployments. The EHR uses a several shared databases for lookup values of CPT codes or drug names so that an update to those can be done once per server and not risk affecting patient data. Since we have all of our production databases on the same SQL cluster, and the structure of one of these tables was changing, we created a workaround. We created a copy of it, appended the version number to the name, then ran an update script on all databases to recreate all views and stored procedures that reference the shared databases to point to our new one. As they are upgraded to the new version, these views and stored procedures get recreated with the default database name.
Now that everyone is on the new version, querying the database I’ve found that not all these objects we changed got touched in the upgrade. I was using sp_helptext to display database objects to me, but it was limiting because it wasn’t searchable.
SELECT name, create_date, modify_date, type, type_desc FROM SYS.OBJECTS WHERE OBJECT_DEFINITION(object_id) LIKE '%ver323%' ORDER BY Name
This returned 153 records. 153 out of 158 were untouched in the upgrade. The column created_date in the query showed the date of the previous upgrade, so I’m deleting from update script the 5 objects that were updated, doing a Find Replace to delete “ver323″ from the script so these get recreated with the default database name. I’ve put this out in QA. I’ll put this in production once I’m convinced it won’t break anything.