0

SQL 2008 : I have created a View ( select * from VW_Test1 ).

This View is targeting table1 and table2.

For some reasons, i renamed these tables as table1_old and table2_old.

I have created new tables as table1 and table2 with new values.

When ever, i am executing the view it gives the same output which it gave before .. i.e) 308 rows affected.

Actually, i am expecting more rows .. Does view stores in buffer like temptable ..

or how to clear and execute again ..? or could be some other reasons ???

1 Answer 1

2

From MSDN - CREATE VIEW:

If a view depends on a table or view that was dropped, the Database Engine produces an error message when anyone tries to use the view. If a new table or view is created and the table structure does not change from the previous base table to replace the one dropped, the view again becomes usable. If the new table or view structure changes, the view must be dropped and re-created.

And:

If a view is not created with the SCHEMABINDING clause, sp_refreshview should be run when changes are made to the objects underlying the view that affect the definition of the view. Otherwise, the view might produce unexpected results when it is queried.

I suggest you DROP and recreate the view.

Sign up to request clarification or add additional context in comments.

3 Comments

I just dropped and recreated the view .. i am still facing the same values !!
@Chok - Are you sure you are using the right database? And that the table names are correct? Do the view and tables all belong to the same schema?
No i figure it out !! Actually, Inside the view .. there was old table mapping !! and now i changed the table !! But thank you oded

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.