9.3. Editing Views with T-SQL

The main thing to remember when you edit views with T-SQL is that you are completely replacing the existing view. The only differences between using the ALTER VIEW statement and the CREATE VIEW statement are:

  • ALTER VIEW expects to find an existing view, whereas CREATE doesn't.

  • ALTER VIEW retains any permissions that have been established for the view.

  • ALTER VIEW retains any dependency information.

The second of these is the biggie. If you perform a DROP and then use a CREATE, you have almost the same effect as using an ALTER VIEW statement. The problem is that youwill need to entirely reestablish your permissions on who can and can't use the view.

Get Professional SQL Server™ 2005 Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.