我是sql得新手,存储过程都看不懂nbu知道该怎么写,请高手们指点.

解决方案 »

  1.   

    create proc abc
    as
    begin
     select * from tb
    end
    exec abc
      

  2.   

    create procedure procedure_select_userInfo_RetrieveUserInfoByNameAndAge
     @name varchar(20),
     @age int
    as
    begin
    select * from userInfo where name=@name and age=@age
    end注意命名规范!!!!!!!
      

  3.   

    create procedure procedure_select_userInfo_RetrieveUserInfoByNameAndAge
     @name varchar(20),
     @age int
    as
    begin
    select * from userInfo where name=@name and age=@age
    end注意命名规范!!!!!!!
      

  4.   

    CREATE PROCDURE P
    AS 
      BEGIN
           SQLSTATEMENT......
      END
      

  5.   


    --其实:有些所谓的高手,以为能写一些复杂的SQL语句,就了不得了,
    --真正想提高速度,还得用存储过程,代码效率高多了!
    --就像我这两天编写的“连续时间问题”
    --我的hist表中有520026条记录行,我测试了一下,我用自己编写的存储过程,用了38秒,
    --用“高手”写的SQL语句,等了十几分钟还没出数据!--一句话:简单的东西,并不一定是效率最高的!
      

  6.   


    --有些SQL语句用到的子查询太多,倒不如用存储过程多写几行代码!