SQL Server review-views and stored procedures

Source: Internet
Author: User

View

A view is actually a query result of one or more tables. The view displays data in a centralized manner, facilitating your query.

Advantages of a view:

1. Data Confidentiality

2. Simplified Query

3. Ensure logical independence of data

Disadvantages of the View:

Updating views is to update the data of basic tables. Some views cannot update data.

1. View with union and other set operations

2. View with group by clause

3. view using functions such as AVG, sum, and Max

4. View with distinct keyword

5. Connecting table View

Common Operations:

Add create view v_name

Modify clter view v_name

Delete drop view v_name

View the view definition exec sp_helptext 'v _ name'

To view the view, see exec sp_depends 'v _ name'

-------------------------------------------------------------------------------

Stored Procedure

Compile and save it in the database

Stored Procedure category:

1. system stored procedures

2. Local stored procedures

3. Temporary stored procedures

A. Local temporary stored procedure (# Name of the first character) can be called only by the currently connected user

B. Global temporary stored procedure (# Name of the START) can be called by all connected users

4. Remote Stored Procedure

5. Extended Stored Procedures (using external language extensions, such as DLL)

Advantages of stored procedures:

1. LocalCodePre-compilation and caching for high-performance data operations

2. The Stored Procedure contains the business logic. When the business changes, you do not need to modify the client.

3. database security can be improved through isolation and Encryption

-------------------------------------------------------------------------------

Comparison of stored procedures and views

1. You can execute a series of SQL statements in a single stored procedure. The view can only be called in select.

2. The view cannot receive parameters and can only return result sets. The stored procedure can accept parameters and return the rest or multiple sets.

3. Views can be called during stored procedures

Related Article

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.