How to determine database string name - SQL Server 2008 r2

I need to find a way to determine which object in the database contains the original database name hardcoded in it. I restored a copy of the database under a different name and ran the homegrown scripts to complete all the naming settings. Say the original database was named ABC_Db, and the restored copy was renamed XYZ_Db. When I try to perform an UPDATE on CoreTable, I get

Invalid object name 'ABC_Db.dbo.CoreTable'

I requested from syscomments and checked various manual checks against relations and indexes, etc. no luck. What's next?

Thank,

John

+3
source share
6 answers

Microsoft SQL Server, RedGate SQL Search - . .

http://www.red-gate.com/products/sql-development/sql-search/

+2

SELECT
   OBJECT_NAME(object_id)
FROM
   sys.sql_modules
WHERE
   definition LIKE '%ABC_Db%'

syscomments .

sys.sql_modules

+3

sys.syscomments - nvarchar (4000), , . .

select quotename(s.name)+'.'+quotename(o.name) as object_name, o.type_desc
    from sys.sql_modules m
        inner join sys.objects o 
            on m.object_id = o.object_id
        inner join sys.schemas s 
            on o.schema_id = s.schema_id
    where m.definition like '%ABC_Db%'
+2

- db , , proc .

0

?

0

SQL Prompt 5 has a "Find Invalid Objects" function that will define stored procedures that reference objects that do not exist. Maybe worth a try.

0
source

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


All Articles