我正在从书中学习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