Is it possible to find out dependent tables for a

2019-09-01 16:30发布

Apparently, one of my views is not responding to any SQL queries. I was wondering if there is a way to find out what tables this view depends on so that I can debug the problem.

I am not an admin on the server so I wouldn't be surprised if this is not possible in the first place but a confirmation would be great. Any suggestions?

3条回答
看我几分像从前
2楼-- · 2019-09-01 17:06

You should get an error message like the one below, if you try the query from Management Studio

Msg 208, Level 16, State 1, Line 1
Invalid object name 'table_missing'.
Msg 4413, Level 16, State 1, Line 1
Could not use view or function 'view_name' because of binding errors.
查看更多
老娘就宠你
3楼-- · 2019-09-01 17:16

Although not infallible, you could start with sp_depends

查看更多
够拽才男人
4楼-- · 2019-09-01 17:21

You just look at the definition of the view

One way (fixed)

SELECT OBJECT_DEFINITION(OBJECT_ID(N'myview'))

This is subject to "metadata visibility" of course and permissions

查看更多
登录 后发表回答