Finding all views

  • Hello,

    I have to change a table name across all servers and I want to find all the views which have dependency to that table. Is there a way to find that out?

    Thank you

  • Here is a way you could find out which views have the table in their definition across one server, assuming your haven't created the view WITH ENCRYPTION

    sp_MSforeachdb @command1 = 'Print ''?''', @command2 = 'select b.name, a.text from ?.dbo.syscomments a inner join ?.dbo.sysobjects b on a.id = b.id and b.type = ''V''

    where a.text like ''%[TableName]%'''

    I don't think you can check for dependencies across servers, if that's what you are trying to do.

    JM

  • the only way you could check across all servers would be if you have linked servers connecting them.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

    The Best of SQL Server Central.com 2002 - http://www.sqlservercentral.com/bestof/

    http://www.dkranch.net

  • Thank you for all your help.

    Actually the result of JM's query, was the the script of all views in the server and I searched for my table name in the result. I did the same for all servers.

  • Thank you for all your help.

    Actually the result of JM's query, was the the script of all views in the server and I searched for my table name in the result. I did the same for all servers.

  • If the view and table are in the same database, EM, table, All Tasks, display dependencies is a nice interactive way to view all dependencies. It's a shame it does not work across databases.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply