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%'

user3453057
  • 55
  • 1
  • 8

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
  • 26,353
  • 15
  • 70
  • 71
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
  • 33,028
  • 3
  • 25
  • 40