SQL SERVER stored procedures and triggers

Source: Internet
Author: User

A stored procedure, a collection of named T-SQL statements stored on a server, is a way to encapsulate repetitive work.

Why use stored procedures?

All clients can ensure consistency of data access and modification through the same stored procedures.

Permissions control, you can individually assign execute permissions for the stored procedure.

The stored procedure is packaged for easy modular design

Stored procedures can reduce network traffic

Create a stored procedure

CREATE Proc[edure] Procedure_name[;number]

[{@parameter data_type}[varting][=default][output][,... n]

[With

{RECOMPILE | Encryption | RECOMPILE |,encryption}]

[For Repilcation]

As SQL_STATEMENT[...N]

eg. create a simple memory

CREATE proc Customers

As

SELECT * FROM Customer information

Go

Execution Memory: Exec customers

Memory containing input parameters

create proc bracelet cost @begincount float, @endcount float

As

If @begincount is null or @endcount is NULL

Begin

RAISERROR (' Null is Disable ', 14,1 ')

Return

End

Select ... where A. Percent of cost between @begincount and @endcount

exec bracelet Cost 65,75

SQL SERVER stored procedures and triggers

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.