SQL Server finds objects that contain strings
SELECTSm.object_id,object_name(Sm.object_id) as object_name, O.type, O.type_desc, Sm.definition fromSys.sql_modules asSMJOINSys.objects asO onSm.object_id =O.object_idwhereSm.definition like '% of content to match%' --Collate SQL_Latin1_General_CP1_CI_ASORDER byO.type;GOSelect object_name(ID) as object_name,text fromsyscommentswhere text like '% of content to match%'--Declare The text we want to search forDECLARE @Text nvarchar(4000);SET @Text = 'What to match';--Get the schema name, table name, and table type for:--Table NamesSELECTTable_schema as 'Object Schema', table_name as 'Object Name', Table_type as 'Object Type' ,'Table Name' as 'TEXT Location' frominformation_schema. TABLESWHEREtable_name like '%'+@Text+'%'UNION --Column NamesSELECTTable_schema as 'Object Schema', column_name as 'Object Name' ,'COLUMN' as 'Object Type' ,'Column Name' as 'TEXT Location' frominformation_schema. COLUMNSWHEREcolumn_name like '%'+@Text+'%'UNION--Function or procedure bodiesSELECTSpecific_schema as 'Object Schema', Routine_name as 'Object Name', Routine_type as 'Object Type', Routine_definition as 'TEXT Location' frominformation_schema. ROUTINESWHERERoutine_definition like '%'+@Text+'%' and(Routine_type= 'function' ORRoutine_type= 'procedure');
SQL Server finds objects that contain strings