SQL Server views

Source: Internet
Author: User
Tags join microsoft sql server
Begin
SQL Server views
Posted by Scott on November 28, 2004
An RDBMS uses a view to create a virtual table. The careful use the views can improve the interaction between a. NET application and the underlying data. In this article we'll discuss views into Microsoft SQL Server, including best practices for creating and using views.
In SQL Server A view represents a virtual table. Just like a real table, a view consists of rows with columns, and your can retrieve data from a view (sometimes even update Data in a view). The fields in the view's virtual table are the fields of one or more real tables in the database. can use views to join two tables in your database and present the underlying data as if the data were coming from a Si Ngle table, thus simplifying the schema of your database for users performing Ad-hoc. can also use views as a security mechanism to restrict the data available to end users. Views can also aggregate data (particularly useful if can take advantage to indexed views), and help partition data. In this article we'll look at the different types of view to? When we can take advantage of a view for our Applicat Ion.
Sample View
The sample database Northwind in SQL Server has a number of views installed by default. One example is the ' current Product List ' view, shown here.
SELECT
Product_list.productid, Product_list.productname
From
Products as Product_list
WHERE (product_list.discontinued = 0)
From inside a application we can issue the following SQL query to retrieve a set of records active products.
SELECT ProductID, ProductName from [current Product List]
The view has created a new virtual table by using records to the Products table and applying a small piece of logic (a F Ilter on the Discontinued field). You are could use the view inside of a query from your application, or a stored procedure, or even to inside view. Views are a simple but powerful abstraction. Can push query complexity, like filter and join statements, in a view to present a simpler model of the data without Sacrificing the database design or integrity.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.