Problem with dependencies

  • Sqlserver 2000 lost dependencies when views is altered. After this all automatic scripts (using dependencies) work whith errors. I find a way for automatic refresh a good dependencies.

    See example :

    CREATE TABLE ta (A1 int, A2 int)

    GO

    CREATE VIEW va AS SELECT * FROM ta

    GO

    CREATE VIEW va2 AS SELECT * FROM va

    GO

    exec sp_depends 'va2'

    GO

    name type updated selected column

    dbo.va view no yes A1

    dbo.va view no yes A2

    This is correct dependenci.

    ALTER VIEW va AS SELECT * FROM ta

    GO

    exec sp_depends 'va2'

    go

    Object does not reference any object, and no objects reference it.

    The dependenci is lost!!!

  • Try sp_refreshview.

  • exec sp_refreshview 'va'

    lost dependencies of va2 !!!

    I need to execute sp_refreshview in order of dependencies !!!???

  • Your 'va2' is depend on 'va' that depends on 'ta'. If there are any changes in either 'ta' or 'va', you have to refresh 'va2' too.

  • My example is very simple. Imagine this with database having hundred of views !!

    I dont understand why sqlserver not have automatic procedure. After you make the change dependencies is lost and you not have way to see how views need refresh, is à good way to go around in circles !

  • You may put change control in place for any this kind of changes.

    Or write a script and schedule it run regularly to refresh all your views.

  • Hi,

    I Finaly write a general procedure to refresh all views of current database in good order

    This procedure work for any database in SQLSERVER 2000.

    See Resources/Scrips SQL Server 7.0/2000 T-SQL aids or Maintenance and Managment

    Thanks to Allen_Cui for his help.

  • Hi,

    I Finaly write a general procedure to refresh all views of current database in good order

    This procedure work for any database in SQLSERVER 2000.

    See Resources/Scrips SQL Server 7.0/2000 T-SQL aids or Maintenance and Managment

    Thanks to Allen_Cui for his help.

Viewing 8 posts - 1 through 7 (of 7 total)

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