Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Find given string in Reporting Services objects

Author  Topic 

cornel
Starting Member

3 Posts

Posted - 2009-01-12 : 05:34:48
Find given string in Reporting Services objects:

How can I find all occurrences of a given string that is used in any SQL Server 2005 Reporting Services databases. (Essential, for example, when trying to identify where a given field name is used in Reporting Services)

I have used the SQL below from within a stored procedure to find all occurrences of a string in a non-Reporting-Services database:

-- Search for the given string in all Procedures, views and Paramenters

(SELECT
ROUTINE_NAME
, SPECIFIC_Catalog as DatabaseName --- Database name that contains the object.
, ROUTINE_TYPE As [Type]
, DATA_Type
, Character_maximum_length
, LAST_ALTERED
, CREATED
, SQL_DATA_ACCESS --reads or modifies
, COLLATION_Name
, Character_set_name
, ROUTINE_BODY
FROM
INFORMATION_SCHEMA.ROUTINES
WHERE
ROUTINE_DEFINITION LIKE @stringToFind -- '%foobar%'
)
UNION ALL (
Select
SPECIFIC_NAME --parameter name
, SPECIFIC_Catalog --- Database name that contains the object.
, 'Parms'
, DATA_TYPE
, Character_maximum_length
, NULL --LAST_ALTERED
, NULL --Created
, Parameter_mode --IN or OUT
, COLLATION_Name
, Character_set_name
, NULL --ROUTINE_BODY
from Information_Schema.parameters --where parameter_name like @stringToFind
WHERE
PARAMETER_NAME LIKE @stringToFind
)
UNION ALL (
Select
TABLE_NAME
, TABLE_Catalog as DatabaseName --- Database name that contains the object.
, 'View'
, NULL -- ROUTINE_TYPE As [Type]
, NULL --Character_maximum_length,
, NULL --LAST_ALTERED
, NULL --Created
, Case is_Updatable
WHEN 'NO' then 'Not Updateable'
WHEN 'YES' then 'Is Updateable'
ELSE is_Updatable end
as SQL_DATA_ACCESS --reads or modifies
, NULL -- COLLATION_Name
, NULL --Character_set_name
, NULL --ROUTINE_BODY

from Information_Schema.views --where view_definition like @stringToFind
WHERE
VIEW_DEFINITION LIKE @stringToFind
)
order by
ROUTINE_NAME, DatabaseName, LAST_ALTERED desc


Best Regards,
Cornel

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-12 : 06:15:57
Cross post http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=117622



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-12 : 08:34:41
If your search yields fieldname,you can use INFORMATION_SCHEMA.COLUMNS .If you are looking for particular strings in database:
http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm
Go to Top of Page
   

- Advertisement -