A reliable way to verify T-SQL stored procedures

后端 未结 6 880
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 15:33

We\'re upgrading from SQL Server 2005 to 2008. Almost every database in the 2005 instance is set to 2000 compatibility mode, but we\'re jumping to 2008. Our testing is compl

6条回答
  •  借酒劲吻你
    2020-12-16 16:22

    Here is what worked for me:

    -- Based on comment from http://blogs.msdn.com/b/askjay/archive/2012/07/22/finding-missing-dependencies.aspx
    -- Check also http://technet.microsoft.com/en-us/library/bb677315(v=sql.110).aspx
    
    select o.type, o.name, ed.referenced_entity_name, ed.is_caller_dependent
    from sys.sql_expression_dependencies ed
    join sys.objects o on ed.referencing_id = o.object_id
    where ed.referenced_id is null
    

    You should get all missing dependencies for your SPs, solving problems with late binding.

    Exception: is_caller_dependent = 1 does not necessarily mean a broken dependency. It just means that the dependency is resolved on runtime because the schema of the referenced object is not specified. You can avoid it specifying the schema of the referenced object (another SP for example).

    Credits to Jay's blog and the anonymous commenter...

提交回复
热议问题