|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, August 04, 2010 2:00 AM
Points: 44,
Visits: 38
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, October 30, 2012 9:13 AM
Points: 24,
Visits: 70
|
|
I wasn't seeing any tables in my results. I think you need a left outer join to sys_columns because Object_Definition on Table returns NULL
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Saturday, June 08, 2013 9:40 AM
Points: 142,
Visits: 286
|
|
I think mine works better: http://www.sqlservercentral.com/scripts/Search/64839/
It hits all databases and includes job steps.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Yesterday @ 7:57 AM
Points: 6,
Visits: 210
|
|
Nice script and great tip on doing the left join to get table info.
SELECT DISTINCT TypeDescription, SchemaName, Name, '...' + SUBSTRING(t.ObjectDefinition, CHARINDEX(@chvStringToFind, t.ObjectDefinition) - @intNbCharToExtract, LEN(@chvStringToFind) + ( @intNbCharToExtract * 2 )) + '...' AS Extract, CreationDate, ModificationDate FROM ( SELECT DISTINCT o.name AS Name, SCHEMA_NAME (o.schema_id) AS SchemaName, o.type_desc AS TypeDescription, o.create_date AS CreationDate, o.modify_date AS ModificationDate, ISNULL(OBJECT_DEFINITION(object_id), c.name) AS ObjectDefinition FROM sys.objects o WITH (NOLOCK) LEFT OUTER JOIN syscolumns c ON c.id = o.object_id WHERE --( -- ( o.type IN ( 'AF', 'FN', 'IF', 'P', 'TF', 'TT', 'U', 'V', 'X' ) -- AND @chrObjectType IS NULL -- ) -- OR o.type = @chrObjectType --) (o.type = @chrObjectType OR @chrObjectType IS NULL) AND (OBJECT_DEFINITION(o.object_id) LIKE '%' + @chvStringToFind + '%' OR c.name LIKE '%' + @chvStringToFind + '%' ) ) AS t ORDER BY 1, 2, 3, 4, 5, 6
|
|
|
|