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

前端之家收集整理的这篇文章主要介绍了sql-server – SQL Server:如何创建存储过程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在从书中学习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
原文链接:https://www.f2er.com/mssql/75944.html

猜你在找的MsSQL相关文章