1

I want to search for the following string in a SP. How should I go about it?

cal.[dbo].[GetNumberOfWorkingDays]

I did not get expected results when I tried

 '%cal.[dbo].[GetNumberOfWorkingDays]%'.

Does it work? : '%cal%GetNumberOfWorkingDays%'

2 Answers2

1

Square bracket is reserved character in SQL Server like operator syntax, so you have to escape it:

like '%cal.\[dbo].\[GetNumberOfWorkingDays]%' escape '\'

See MSDN for details.

Andrey Korneyev
  • 25,929
  • 15
  • 67
  • 67
1

Another option would be to use CHARINDEX instead of LIKE. Since I am guessing this is in a where clause it would be something like this.

WHERE CHARINDEX('cal.[dbo].[GetNumberOfWorkingDays]', YourColumn, 0) > 0

https://msdn.microsoft.com/en-us/library/ms186323.aspx

Sean Lange
  • 31,919
  • 3
  • 24
  • 38