-1

I am trying to select certain stored procedures within my database.

What I want is all stored procedures that start with Get_ but I cannot get proper results. It seems to ignore the _ for some reason. Running SQL Server 2019 developer version.

Here is my code:

select * 
from information_schema.routines 
where routine_type = 'PROCEDURE' and specific_name like 'Get_%'
Dale K
  • 25,246
  • 15
  • 42
  • 71
duerzd696
  • 304
  • 1
  • 8

1 Answers1

4

The underscore _ character is a wildcard in SQL Server t-sql. Use LIKE 'Get[_]%' to explictly match an actual underscore in the string.

From the documentation - "[ ] (Wildcard - Character(s) to Match)":

Matches any single character within the specified range or set that is specified between brackets [ ]. These wildcard characters can be used in string comparisons that involve pattern matching, such as LIKE and PATINDEX.

squillman
  • 13,363
  • 3
  • 41
  • 60