January 27, 2014 at 8:11 am
We have a commercial app that fires several stored procs at the begining. Now sure which one of them is throwing an error ( Says something like column ferral_orr not found ).
I know for sure it is coming from some code in a stored proc. Is there a guru out there who can write a SQl statemet that can parse the DB for all stored proc definitions and find out which stored proc is responsible for the alert ?
So to make a long story short, can I search the database for stored proc definitions and search for a key word "referall_orr"
January 27, 2014 at 8:21 am
mw112009 (1/27/2014)
We have a commercial app that fires several stored procs at the begining. Now sure which one of them is throwing an error ( Says something like column ferral_orr not found ).I know for sure it is coming from some code in a stored proc. Is there a guru out there who can write a SQl statemet that can parse the DB for all stored proc definitions and find out which stored proc is responsible for the alert ?
So to make a long story short, can I search the database for stored proc definitions and search for a key word "referall_orr"
pretty straight forward to find, there's a built in meta data view to use!:
select object_name(object_id), definition from sys.sql_modules WHERE definition like '%referall_orr%'
Lowell
January 27, 2014 at 9:13 am
Works well but here is a related question. How can we search specifically for the the word "referrals_orr"
I know that SQL server thinks of "_" as any common character. I know for sure there is a way to search for
special characters. Can it be the '\' character infront of the _ ?
The following will returns entries like referralsaorr ( I don't want that )
SELECT
obj_name
FROM
#r
WHERE
PATINDEX('%'+ 'referrals_orr' +'%', sp_def) > 0;
January 27, 2014 at 9:28 am
Quote the special character. Example:
create table #test (
string varchar(100));
insert into #test(string) values('001');
insert into #test(string) values('101');
insert into #test(string) values('1_1');
insert into #test(string) values('0_1');
select * from #test where string like '1[_]%';
select * from #test where string like '1%';
drop table #test;
HTH
January 27, 2014 at 9:29 am
and another way:
you can declare an explicit escape char like this:
select
object_name(object_id),
definition
from sys.sql_modules
WHERE definition like '%referall!_orr%' ESCAPE '!'
Lowell
January 27, 2014 at 9:31 am
Lowell (1/27/2014)
and another way:you can declare an explicit escape char like this:
select
object_name(object_id),
definition
from sys.sql_modules
WHERE definition like '%referall!_orr%' ESCAPE '!'
I like this way better - easier to read.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply