zoukankan      html  css  js  c++  java
  • 温故而知新--sql存储过程复习

    存储过程是已编译好的T-SQL语句的集合,可以随时调用,速度快,不易出错。

    可以传递参数,普通参数和输出参数(output)

    实例1

    create proc Newpro

    @testVarA int,

    @testVatB int,

    @testSum int Output

    as

    begin

    set @testSum=@testVarA+@testVarB

    end

    调用存储过程Newpro

    declare @testA int

    execute Newpro 100,200,@testA output

    print @testA

    实例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='欢迎进入'

         else

         set @testMsg='对不起,密码错误'

         end

    else if @testUserName='user2'

         begin

          if @testPassWord='abc'

          set @testMsg='欢迎进入'

          else

          set @testMsg='对不起,密码错误'

         end

    else

          set @testMag='请输入正确的用户名'

    print @testMsg

    end

    调用存储过程testUser

    exec testUser 'user1','123'

  • 相关阅读:
    (一〇八)iPad开发之横竖屏适配
    ZOJ 1414:Number Steps
    HDU 1391:Number Steps
    ZOJ 1871:Steps
    POJ 2590:Steps
    POJ 2629:Common permutation
    POJ 2562:Primary Arithmetic
    POJ 2505:A multiplication game
    HDU 1517:A Multiplication Game
    POJ 3650:The Seven Percent Solution
  • 原文地址:https://www.cnblogs.com/chenliyang/p/6595373.html
Copyright © 2011-2022 走看看