MSSQL stored procedures (long notes, turned out to miss the next)

Source: Internet
Author: User
Tags modifier mssql

Syntax structure:

Create proc name     parameter list      as       Code Snippet

Call:

exec Stored procedure name parameter list

Points:

1 . You can use the output modifier parameter 2. You can use the default values, note that you need to set the last parameter to the default value

Instance:

1 --easy to get started stored procedure procedure2 Create procTri3 @str varchar(Ten)4  as5 Declare @str1 varchar(Ten)6 Set @str1=LTRIM(RTRIM(@str))7 Print @str18 9 --Call: ExecTen execTri'ABC'     One --stored procedure output with return value A --ask for two numbers and - Create procsuml - @num1 int , the @num2 int, - @result intOutput--indicates that this parameter can take the result out of the stored procedure -  as  - Set @result=@num1+@num2 +  - Declare @r int + execSuml1,2,@rOutput--The OUTPUT keyword must be written, or an error is called A Print @r at  - --parameter stored procedure with default value, Ps: The default value must be the last parameter - Alter procMulti - @num1 int, - @num2 int=TenOutput--The output function is similar to the ref modifier parameter in C # -  as  in Set @num2=@num2*@num1 - Print @num2 to --test the effect of bringing out values + Declare @num int=2 - execMulti3,@numOutput the Select @num *  $  

MSSQL stored procedures (long notes, turned out to miss the next)

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.