Regarding Views

  • hi friedns,

    I have one situation...we have here more then 250 views directed to database db1 like all views having from db1..sometable.

    now we have to change these 250 views to db2..sometable .

    so i have to go to each view and change it manually...

    any other way we can do by wrting any sp or code?

    any suggestion will be appreciated.... thx in advance...

    Mithun

  • You could loop through all views and replace db1 with db2 in the text returned by sp_helptext @viewName.To get an alter statement you will have to replace again CREATE with ALTER.

    Could this fit your needs?

    -- Gianluca Sartori

  • You could also create synonyms in db1 for the tables in db2.

    I don't like this solution anyway, it's not very clean.

    -- Gianluca Sartori

  • yeah this coluld be done , i can loop this view and using sp_helptext i can replace db1 with db2... seems cool let me give it a try ....

    thx a lot

    Mithun

  • OBJECT_DEFINITION works nicely for views.

    You can also look in the definition column of sys.sql_modules - join from sys.views to see only the view definitions.

    Paul

  • HEY PAUL

    THANKS FOR THIS ONE sys.sql_modules ...

    it really helped me...

    Mithun

  • No worries.

  • post moved to general sql server 2008 forum

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

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