declare @SearchFor varchar(100);
set @SearchFor = 'blah blah blah';
if left(@SearchFor, 1) != '%' set @SearchFor = '%' + @SearchFor;
if right(@SearchFor, 1) != '%' set @SearchFor = @SearchFor + '%';
s.name as SchemaName
,o.name as ObjectName
,o.type_desc as ObjectTypeDesc
,o.is_ms_shipped as IsMSShipped
,'exec sp_helptext ''[' + s.name + '].[' + o.name + ']'';' as GetCode
inner join sys.objects o
on sm.object_id = o.object_id
inner join sys.schemas s
on o.schema_id = s.schema_id
definition like @SearchFor -- What we are looking for
and o.is_ms_shipped = 0 -- Not a Microsoft bit of code
Edit - 20101015: It's worth nothing that this is not the most efficient piece of code, and that there is a free RedGate product out there that will search your SQL instance for you (SSMS integrated):
Monday, 8 February 2010
I have a SVN repo on my local machine that I have been shoving stuff into since before I knew how to use revision control systems properly (...
As time goes on, the world is becoming more-and-more automated by software. This essentially also means that there is an exponentially growi...
It's been a while since I made a purely technical post... So, today I wanted to make a change to a Microsoft Team Foundation Server 20...
Another purely technical post on TFS... The scenario We wish to migrate code between branches that do not have a branch/merge relationsh...