SQL script to change all table references in all stored procedures
问题 I have created a new database with copies of existing tables but changed the names of these tables, is there a SQL script that I can run (maybe using SysObjects) to change all references to these tables in all stored procedures? 回答1: DO NOT RELY ON INFORMATION_SCHEMA.ROUTINES because ROUTINE_DEFINITION is only nvarchar(4000) . You need to sys.sql_modules where definition is nvarchar(max) try any of these to find the procedure that you need to modify: SELECT DISTINCT LEFT(s.name+'.'+o.name,