• kapil190588 (10/10/2012)


    Hi Hugo,

    according to another QOD i.e view 5

    there was condition that if a add a new column to the table (previously there were 5 columns) and didnt refresh the view then view return only 5 rows. It will return 6 column when we alter or refresh he view.

    You told that view do not get effect untill we refresh it or alter.

    so why in this question if we drop a column n thn do SELECT * FROM VOrder_Details,

    in this condition also 5 columns should get return as view not altered nor refereshed.

    I am confused with view behaviour. :w00t:

    can you plz explain ?

    One of the examples in the sample code I posted in that topic covered this scenario. I can't find the topic now (and I don't have the time to hunt it down), but if you look for the discussion and check the code again, I'm sure you'll recognize it.

    In this scenario, since the view was not refreshed, it tries to fetch five columns from the base table. But since one of the five was dropped, the base table now has only four columns. So you get an error. I believe the message is something like "more column definitions then there are columns".


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/