Wrong object_name and definition relationship in sys.sql_modules and sys.objects
问题 I ran the following query SELECT sm.object_id, v1.object_name, o.type, o.type_desc, sm.definition FROM sys.sql_modules sm CROSS APPLY (VALUES (OBJECT_NAME(sm.object_id))) v1 (object_name) JOIN sys.objects o ON sm.object_id = o.object_id; And there are three objects with a wrong relation between object_name and definition . There is no match, no correspondence between the name and the definition it references. It looks like this tables didn't track the delete or changes in name and definitions