SQL Server 2000: View Basics

INSTEAD OF trigger on a View

SQL SERVER 2000 allows triggers on a View. That’s really great. Previous version of SQL SERVER did not allow this. Again, this is a new feature in SQL SERVER 2000. But remember you can create only INSTEAD OF triggers on Views.

CREATE VIEW vwSample

As

SELECT

          CustomerID,

          CompanyName,

          ContactName

FROM DBO.CUSTOMERS

GO

Limitations of Views

There are some limitations when using Views. They are:

  • SELECT INTO cannot be used in the View
  • Temporary tables cannot be used within the View
  • Parameterized views does not exists i.e., you cannot pass parameters to the Views
  • COMPUTE & COMPUTE BY clauses cannot be used within the View

Views and User-Defined Functions

Views and User-Defined Functions almost serve the same purpose. But the major difference is that User-Defined Function can accept parameters, whereas Views cannot. And also the output of the User Defined Function can be directly used in the SELECT clause, whereas you cannot do it with a View.

Summary

Views are nothing but saved SQL statements. User can insert, delete or update the data using the Views in SQL SERVER 2000. Indexes and Triggers can also be created on Views, with an exception that the first Index should be UNIQUE CLUSTERED INDEX and the trigger should be INSTEAD OF trigger. Views and User-Defined Functions serve almost the same purpose with an exception that User-Defined Functions accept parameters, whereas Views will not.

Navneeth Diwaker Naik (navneeth_naik@satyam.com) is an employee of Satyam Computers Services Limited, Hyderabad, Andhra Pradesh. [INDIA].

Published with the explicit written permission of the author. Copyright 2004.

Pages: 1 2 3




Related Articles :

  • No Related Articles Found

No comments yet... Be the first to leave a reply!

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |