August 4, 2010 at 9:48 am
was building a simple script to refresh all my views, since some columns were added to some base tables and *gasp* the views use "SELECT * FROM SOMETABLE"
yeah i know... [insert admonishments here]
anyway, some of the views are bound to a schema...[production].viewname, [lookups.viewname] etc....
the command fails, as sp_refreshview does not allow a schema:
exec sp_refreshview [lookups].[states]
exec sp_refreshview [dbo].[states]
exec sp_refreshview lookups.states
exec sp_refreshview dbo.states
exec sp_refreshview [states] --ok for dbo, but not for [lookups] schema
anyway, I cursored thru with an ALTER command for each view, so problem solved...always more than one way to tackle a problem with SQL....but in theory, how do you use sp_refreshview on a schema bound view not owned by dbo?
Lowell
August 4, 2010 at 10:05 am
May 11, 2011 at 9:28 am
I have this same problem and even the '[userOfView].[viewName]' syntax does not work for me when run as "sa". Apparently sp_refreshview was modified to call sp_refreshsqlmodule, which also doesn't work for me when run as "sa", but both do work when connected as "userOfView".
sp_refreshview '[userOfView].[viewName]'
sp_refreshsqlmodule '[userOfView].[viewName]'
both return:
Msg 208, Level 16, State 6, Procedure sp_refreshsqlmodule_internal, Line 75
Invalid object name 'viewName'.
ps> this worked just fine in SqlServer2005, and SqlServer2008 (10.0.1600), but not in SqlServer2008-R2 (10.50.1600)
May 11, 2011 at 9:34 am
Does this example look like the answer or did I misunderstand your question?
USE AdventureWorks2008R2;
GO
EXECUTE sp_refreshview N'Sales.vIndividualCustomer';
I found it at the following URL:
http://msdn.microsoft.com/en-us/library/ms187821.aspx
Regards,
Welsh
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
May 11, 2011 at 9:35 am
steve.hale (5/11/2011)
I have this same problem and even the '[userOfView].[viewName]' syntax does not work for me when run as "sa". Apparently sp_refreshview was modified to call sp_refreshsqlmodule, which also doesn't work for me when run as "sa", but both do work when connected as "userOfView".sp_refreshview '[userOfView].[viewName]'
sp_refreshsqlmodule '[userOfView].[viewName]'
both return:
Msg 208, Level 16, State 6, Procedure sp_refreshsqlmodule_internal, Line 75
Invalid object name 'viewName'.
ps> this worked just fine in SqlServer2005, and SqlServer2008 (10.0.1600), but not in SqlServer2008-R2 (10.50.1600)
Please post a new thread. You'll get more help that way anyways.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply