SELECT name, type_desc FROM sys.all_sql_modules s INNER JOIN sys.all_objects o ON s.object_id = o.object_id WHERE definition LIKE '%關鍵字%' ORDER BY typ... ...
SELECT name, type_desc FROM sys.all_sql_modules s INNER JOIN sys.all_objects o ON s.object_id = o.object_id WHERE definition LIKE '%關鍵字%' ORDER BY type_desc, name;
SELECT name, xtype FROM sysobjects o, syscomments s WHERE o.id = s.id AND text LIKE '%agent%';
--查詢所有包含某列名的對象 SELECT name, object_id, type, type_desc FROM sys.objects WHERE object_id IN ( SELECT object_id FROM sys.columns WHERE name = 'serverid' );