Chapter 7 WORKING WITH VIEWS 413 .AuthorShortInfo, Line
Chapter 7 WORKING WITH VIEWS 413 .AuthorShortInfo, Line 2 Invalid column name city . Server: Msg 4413, Level 16, State 1, Line 1 Could not use view or function AuthorShortInfo because of binding errors. This error states that a required object (the city column) no longer exists. This problem is possible, and can easily occur, because of the lack of checking on changes to source objects. This same error message would result if you execute sp_refreshview on AuthorShortInfo, and sp_refreshview would return a non-zero value because of the failure. It is possible to create a small procedure to query sysobjects for views, loop them through them, and refresh each view to ensure that they are all still valid. Dropping Views To remove a view from a database, use the DROP VIEW statement. Dropping a view removes the definition of the view from the database and an entry in the sysobjects while not affecting the underlying tables and views. The DROP VIEW command is relatively simple as shown here: DROP VIEW { view } [ ,…n ] To drop a view named my_view, you simply have to execute DROP VIEW my_view . With the DROP VIEW command you may also choose to remove a number of views at the same time. To do this, specify each view in a comma-delimited list. Dropping an indexed view leads to the removal of all indexes associated with that view. To drop the view created in Step by Step 7.4, enter and run the following code: DROP VIEW EmployeeView GO If you drop a view that is used by another object, such as a view, you cause problems with the dependent view. For example, examine the following code: CREATE VIEW auth1 AS SELECT au_fname, au_lname, city, state FROM pubs.dbo.authors GO CREATE VIEW auth2 AS SELECT au_fname, au_lname FROM pubs.dbo.auth1 WARNING Dropping Used Views Dropping views that are used by other views causes the dependent views to stop working, because the object that they refer to no longer exists.
For high quality website hosting services please check cheap web hosting website.