October 5, 2016 at 10:08 am
Comments posted to this topic are about the item Refresh all views in a database
Thanks.
October 28, 2016 at 3:49 pm
Good one. Simple and Easy.
Thanks,
Naveen.
Every thought is a cause and every condition an effect
October 31, 2016 at 7:14 am
I didn't know you could do this, thanks.
December 7, 2016 at 7:20 am
Just circling back to say thanks for this tip.
January 28, 2018 at 10:24 am
I seem to recall this script was plagiarised recently, which seems to have been sorted, but I recall a very pertinent question on that thread about 'what if the schema was different'. Without wishing to take anything from the original Author or Authors, perhaps this may work (there may be better solutions):
DECLARE @sqlcmd NVARCHAR(MAX) = ''
SELECT @sqlcmd = @sqlcmd + 'EXEC sp_refreshview ''' + TABLE_SCHEMA + '.'+ TABLE_NAME + ''';'
FROM INFORMATION_SCHEMA.tables ISV
WHERE ISV.TABLE_TYPE = 'VIEW'
SELECT @sqlcmd
...
January 29, 2018 at 10:46 am
Heh... not only different schema but the quite different problem of a view that uses the WITH SCHEMABINDING directive. You might also want to think about NOT rebuilding Indexed Views and the very real problems associated with views in general if they actually do need to be refreshed even in the face of column additions. There are exceptions, of course, but generally not.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply