Is there a way to have SQL server validate object references in Stored Procs?

后端 未结 7 2088
半阙折子戏
半阙折子戏 2021-01-13 20:12

The following code executes fine in SQL Server

create proc IamBrokenAndDontKnowIt as
select * from tablewhichdoesnotexist

Of course if I tr

7条回答
  •  生来不讨喜
    2021-01-13 21:15

    You could run sp_depends (see http://msdn.microsoft.com/en-us/library/ms189487.aspx) and use that information to query the information schema (http://msdn.microsoft.com/en-us/library/ms186778.aspx) to see if all objects exist. From what I read here (http://msdn.microsoft.com/en-us/library/aa214346(SQL.80).aspx) you only need to check referenced tables, which is doable.

提交回复
热议问题