The new--sql stored process review

Source: Internet
Author: User

A stored procedure is a collection of compiled T-SQL statements that can be called at any time, fast and error-prone.

Parameters can be passed, common parameters and output parameters (outputs)

Example 1

Create proc Newpro

@testVarA int,

@testVatB int,

@testSum int Output

As

Begin

set @[email protected][email protected]

End

Call the stored procedure Newpro

DECLARE @testA int

Execute Newpro 100,200, @testA output

Print @testA

Example 2

Create proc TestUser

@testUserName varchar (30),

@testPassWord varchar (30)

As

Begin

declare @testMsg varchar (100)

If @testUserName = ' user1 '

begin

If @testPassWord = ' 123 '

Set @testMsg = ' Welcome entry '

Else

Set @testMsg = ' Sorry, bad password '

End

else if @testUserName = ' user2 '

begin

If @testPassWord = ' abc '

Set @testMsg = ' Welcome entry '

Else

Set @testMsg = ' Sorry, bad password '

End

Else

Set @testMag = ' Please enter the correct user name '

Print @testMsg

End

call the stored procedure testUser

exec testUser ' user1 ', ' 123 '

The new--sql stored process review

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.