One of our tables is loosing a column and related views need to be refreshed. I ran the procedure sp_refreshview ok on it's own for one view, although I had to pick the actual database, even though I had the DB.dbo.View_name
extension.
I am now wanting to run a few of these update view statements in one script that does the table update too, but keep getting this error message saying incorrect syntax near sp_refreshview. I have tried putting go after the statement to contain it, with the USE [DB_Name]
statement before each update. Like below:
use [DB1]
sp_refreshview 'DB1.dbo.View1'
go
use [DB2]
sp_refreshview 'DB2.dbo.View1'
go
It keep failing for some reason. Granted this is the first time I have set a batch script to update multiple views in different DBs so if there is a better way to do this I am open to suggestions.