issue while selecting from a view

  • Hello,

    I have a client running SQL Server 2000 SP3a on Windows 2000. This past weekend we had a wierd issue wherein a select statement on a view was just timing out for some reason. It's a simple view with a select statement from a single table. Once I dropped and created the view, everything started working normally. Just wondering if anybody has come across this issue and the reason for this happening.

    Thanks.

     

  • By any chance, did you change the underlying table structure? If so, you might want to read about sp_refreshview in BOL.

     

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • the sp_refreshview works.  You can also use QA to resecript the dependent view using "ALTER" and rerun.  SQL seems to store column orders as the reference in the view, so if the underlying table changes, the view won't work, or worse, columns will appear to be working but contain the wrong column's data.

     

    This is a nice feature if you need to change a table structure because related views although "breaking", will not prvent the changes.  If you are making many table structure changes and have a lot of depended objects, I suggest rescripting all the views, procedures and functions using EM to refresh all objects to ensure none are broken.  There is some script to run sp_refreshview on all views in a db, but I don't know it.

  • Thanks a lot for responding. But, the table structure was not changed. I have started thinking that maybe the view definition was corrupted. But, I have never heard of view corruption before, have any of you ?

     

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

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