Yet another SQL Server DBA…

Just another SQL Server DBA blog

Posts Tagged ‘views’

How to check definition of views in a database

Posted by Szymon Wójcik on October 7, 2011

During preparation of replication from remote site to central office I stumbled upon a need to check definitions of all views in a database. The script is simple, yet useful:

select sv.name, sc.text from sys.views sv 
inner join dbo.syscomments sc on sv.object_id = sc.id
where sv.is_ms_shipped = 0 

You get all the non-system views – if you’re looking for a specific text in a script, just drop another conditions in WHERE clause and you’re done. I – for instance – was able to locate all views referencing linked servers.

Posted in SQL Server | Tagged: , , , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 45 other followers