Wednesday, August 15, 2012

validate all the views in sql server

some of the views in one of our database are failing as we used to move the underlying tables to a different archival database in a job. so I was trying to find any system sp to validate all the views but didn't found any thing specifically to this. luckily there is an sp that validates the metadata and the the same sp we can use to validate as well. if the underlying table in the view doesn't exist then it will produce an error.

not sure if there is any other way to do it , but I found this as a shortcut.

set nocount on
select ' print ''' +name +'''
exec sp_refreshview ['+name+']' + '

go '
from sys.views

2 comments:

  1. Nice, but how to also include the Schema?

    ReplyDelete
  2. Somebody necessarily help to make severely posts I would state.
    That is thee very first time I frequented your web page and thus far?
    I amazed with the research you made to creare tjis particular publish extraordinary.
    Great task!

    ReplyDelete

Featured Post

SQL Server AWS Migration BCP

stored procedure to generate BCP scritps to migrate the SQL Server database. Developed this stored procedure on my labs to simulate t...

Contributors