Select "Request" using the same item in Sql server 2008

Table name  : sp_text  
Column name : obj_Text

In this column, all stored procedures are stored as text.

I need to get all stored procedures with raiserrorand % d in raiserror.

for example, A SP contains the following in it raiserror.

raiserror('quantity adjustment is not allowed in row no %d', 16, 1, @fprowno)  

I tried the following query, but could not reach the result.

select *
from   sp_text_ismail 
where  obj_Text like '%raiserror%'
  and  obj_Text like '%/%d%'
+3
source share
2 answers

Use the sys.sql_modules system view : much simpler. And you can avoid% with parentheses in LIKE

SELECT OBJECT_NAME(object_id), * FROM sys.sql_modules
WHERE definition LIKE '%raiserror%[%]d%'

You also cannot select or filter a stored procedure.

+3
source

escape- '\' , . . escape char, .

select * from sp_text_ismail where obj_Text like '%raiserror%' and obj_Text like '%\%d%' ESCAPE '\'
-1

Source: https://habr.com/ru/post/1784464/


All Articles