I need to execute sp_refreshview
on the other database by using the created linked server.
For example, I have linked server Demo_LinkedServer
. In the AdventureWorks
database, I have created a table Demo_TBL
and on top of the table, created a view named VW_Demo_TBL
.
Now, I am in a database Demo_Database
. How I could execute sp_refreshview
in AdventureWorks
by using linked server Demo_LinkedServer
?
First attempt:
exec Demo_LinkedServer.AdventureWorks.dbo.sp_refreshview N'dbo.VW_Demo_TBL'.
I get the error:
Server 'Demo_LinkedServer' is not configured for RPC.
Second attempt:
SELECT *
FROM OPENQUERY(Demo_LinkedServer,
'EXEC sp_refreshview N''dbo.VW_Demo_TBL''')
Now I get this error:
Msg 11528, Level 16, State 1, Procedure sys.sp_describe_first_result_set, Line 1 [Batch Start Line 118]
The metadata could not be determined because statement 'EXEC %%TriggerEx(MultiName = @name).LockMatchID(ID = @objid, Exclusive = 1, NameSpaceClass = @ns)' in procedure 'sp_refreshsqlmodule_internal' does not support metadata discovery.
I finally found an easy way. The issue was that I needed to specify the @ViewName for calling the SP sp_refreshview.
EXEC AdventureWorks.dbo.sp_refreshview @ViewName=N'dbo.VW_Demo_TBL'
I hope this can help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.