Skip to main content
Rollback to Revision 15
Source Link
Mahmoud Gamal
  • 80.2k
  • 18
  • 143
  • 168

Escape the square brackets:

... WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Then the square brackets will be treated as a string literals not as wild cards.

The whole query is

SELECT DISTINCT o.name AS Object_Name, o.type_desc FROM sys.sql_modules m INNER JOIN sys.objects o ON m.object_id = o.object_id WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Escape the square brackets:

... WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Then the square brackets will be treated as a string literals not as wild cards.

The whole query is

SELECT DISTINCT o.name AS Object_Name, o.type_desc FROM sys.sql_modules m INNER JOIN sys.objects o ON m.object_id = o.object_id WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Escape the square brackets:

... WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Then the square brackets will be treated as a string literals not as wild cards.

added 281 characters in body
Source Link
asmgx
  • 8.2k
  • 19
  • 102
  • 185

Escape the square brackets:

... WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Then the square brackets will be treated as a string literals not as wild cards.

The whole query is

SELECT DISTINCT o.name AS Object_Name, o.type_desc FROM sys.sql_modules m INNER JOIN sys.objects o ON m.object_id = o.object_id WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Escape the square brackets:

... WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Then the square brackets will be treated as a string literals not as wild cards.

Escape the square brackets:

... WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Then the square brackets will be treated as a string literals not as wild cards.

The whole query is

SELECT DISTINCT o.name AS Object_Name, o.type_desc FROM sys.sql_modules m INNER JOIN sys.objects o ON m.object_id = o.object_id WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 
Rollback to Revision 13
Source Link
Mahmoud Gamal
  • 80.2k
  • 18
  • 143
  • 168

Escape the square brackets:

... WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Then the square brackets will be treated as a string literals not as wild cards.


Alternative Method:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE '%Foo%' AND ROUTINE_TYPE='PROCEDURE' 

Escape the square brackets:

... WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Then the square brackets will be treated as a string literals not as wild cards.


Alternative Method:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE '%Foo%' AND ROUTINE_TYPE='PROCEDURE' 

Escape the square brackets:

... WHERE m.definition Like '%\[ABD\]%' ESCAPE '\' 

Then the square brackets will be treated as a string literals not as wild cards.

Rollback to Revision 12
Source Link
Brian Webster
  • 31k
  • 51
  • 158
  • 227
Loading
Rollback to Revision 9
Source Link
Mahmoud Gamal
  • 80.2k
  • 18
  • 143
  • 168
Loading
Rollback to Revision 10
Source Link
Brian Webster
  • 31k
  • 51
  • 158
  • 227
Loading
Rollback to Revision 7
Source Link
Mahmoud Gamal
  • 80.2k
  • 18
  • 143
  • 168
Loading
Rollback to Revision 8
Source Link
Brian Webster
  • 31k
  • 51
  • 158
  • 227
Loading
Rollback to Revision 4
Source Link
Mahmoud Gamal
  • 80.2k
  • 18
  • 143
  • 168
Loading
Rollback to Revision 6
Source Link
Brian Webster
  • 31k
  • 51
  • 158
  • 227
Loading
Rollback to Revision 4
Source Link
Mahmoud Gamal
  • 80.2k
  • 18
  • 143
  • 168
Loading
added 23 characters in body
Source Link
Brian Webster
  • 31k
  • 51
  • 158
  • 227
Loading
Rollback to Revision 3
Source Link
Brian Webster
  • 31k
  • 51
  • 158
  • 227
Loading
Rollback to Revision 2
Source Link
Mahmoud Gamal
  • 80.2k
  • 18
  • 143
  • 168
Loading
added 173 characters in body
Source Link
Brian Webster
  • 31k
  • 51
  • 158
  • 227
Loading
edited body
Source Link
Mahmoud Gamal
  • 80.2k
  • 18
  • 143
  • 168
Loading
Source Link
Mahmoud Gamal
  • 80.2k
  • 18
  • 143
  • 168
Loading