SQL Server All View Refresh

  • Comments posted to this topic are about the item SQL Server All View Refresh

    SQL Server Consultant
    yusufkahveci@sqlturkiye.com
    www.sqlturkiye.com

  • So, what happens when the view is in a schema other than the default schema of the user using the script? 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • How about this

    DECLARE
     @sqlTrexec NVARCHAR(MAX)='';

    SELECT @sqlTrexec = @sqlTrexec + '
    EXECUTE sp_refreshview N''' + QUOTENAME( SS.Name ) + '.' + QUOTENAME( SO.Name ) + ''';'
    FROM sys.objects AS SO
    INNER JOIN sys.schemas AS SS ON SO.SCHEMA_ID = SS.SCHEMA_ID
    WHERE SO.TYPE='V'
    ORDER BY SS.Name, SO.Name;

    EXECUTE (@sqlTrexec);

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply