加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sql-server – SQL Server:如何创建存储过程

发布时间:2020-12-12 08:33:20 所属栏目:MsSql教程 来源:网络整理
导读:我正在从书中学习sql,我正在尝试编写一个存储过程,但我不相信我正在做这个.以下方式在Microsoft SQL中无效?如果没有,什么时候有效,如果有的话? create procedure dept_count(in dept_name varchar(20),out d_count integer) begin select count(*) into d_c
我正在从书中学习sql,我正在尝试编写一个存储过程,但我不相信我正在做这个.以下方式在Microsoft SQL中无效?如果没有,什么时候有效,如果有的话?
create procedure dept_count(in dept_name varchar(20),out d_count integer)
   begin
     select count(*) into d_count
     from instructor
     where instructor.dept_name=dept_count.dept_name
   end

我收到以下错误

Msg 156,Level 15,State 1,Procedure wine_change,Line 1
Incorrect syntax near the keyword ‘in’.

解决方法

T-SQL
/* 
Stored Procedure GetstudentnameInOutputVariable is modified to collect the
email address of the student with the help of the Alert Keyword
*/



CREATE  PROCEDURE GetstudentnameInOutputVariable
(

@studentid INT,--Input parameter,Studentid of the student
@studentname VARCHAR (200) OUT,-- Output parameter to collect the student name
@StudentEmail VARCHAR (200)OUT     -- Output Parameter to collect the student email
)
AS
BEGIN
SELECT @studentname= Firstname+' '+Lastname,@StudentEmail=email FROM tbl_Students WHERE studentid=@studentid
END

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读