USE Thesis_designsystem
IF EXISTS (SELECT name FROM sysobjects
where name = 'proc_tGuideLimit' AND type = 'P')
drop procedure proc_tGuideLimit
GOCreate procedure proc_tGuideLimit
@teacher_work_id char(10),
@flag tinyint outputDeclare @curr_num int,
@max_num intas
select @curr_num=count(teacher_work_id),
@max_num=max_guide
from Thesis_choose_result T join Give_guide_limit G on T.teacher_work_id=G.teacher_work_id
where T.teacher_work_id=@teacher_work_id
If (@max_num - @curr_num)>0
@flag=1
else
@flag=0
Go
服务器: 消息 170,级别 15,状态 1,过程 proc_tGuideLimit,行 3
第 3 行: ',' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,过程 proc_tGuideLimit,行 9
在关键字 'as' 附近有语法错误。
服务器: 消息 137,级别 15,状态 1,过程 proc_tGuideLimit,行 13
必须声明变量 '@teacher_work_id'。
服务器: 消息 170,级别 15,状态 1,过程 proc_tGuideLimit,行 15
第 15 行: '@flag' 附近有语法错误。我想根据提供的参数 @teacher_work_id 然后检查该@teacher_work_id在当前表 Thesis_choose_result 中的记录是否超出最大限制。没有@flag=1 已经超过@flag=0!
请各位 大哥看看,不胜感激!
IF EXISTS (SELECT name FROM sysobjects
where name = 'proc_tGuideLimit' AND type = 'P')
drop procedure proc_tGuideLimit
GOCreate procedure proc_tGuideLimit
@teacher_work_id char(10),
@flag tinyint outputDeclare @curr_num int,
@max_num intas
select @curr_num=count(teacher_work_id),
@max_num=max_guide
from Thesis_choose_result T join Give_guide_limit G on T.teacher_work_id=G.teacher_work_id
where T.teacher_work_id=@teacher_work_id
If (@max_num - @curr_num)>0
@flag=1
else
@flag=0
Go
服务器: 消息 170,级别 15,状态 1,过程 proc_tGuideLimit,行 3
第 3 行: ',' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,过程 proc_tGuideLimit,行 9
在关键字 'as' 附近有语法错误。
服务器: 消息 137,级别 15,状态 1,过程 proc_tGuideLimit,行 13
必须声明变量 '@teacher_work_id'。
服务器: 消息 170,级别 15,状态 1,过程 proc_tGuideLimit,行 15
第 15 行: '@flag' 附近有语法错误。我想根据提供的参数 @teacher_work_id 然后检查该@teacher_work_id在当前表 Thesis_choose_result 中的记录是否超出最大限制。没有@flag=1 已经超过@flag=0!
请各位 大哥看看,不胜感激!
//标点是汉字的符号,改用英文的
在关键字 'as' 附近有语法错误。
//存储过程参数区的变量不用Declare声明
必须声明变量 '@teacher_work_id'。
//没有声明变量
第 15 行: '@flag' 附近有语法错误。
//给变量赋值前面要加Select或Set 如:Select @flag=1
@max_num int
要做参数那还是做sp的变量
做变量放在 as后面
做参数去掉declare
....
USE Thesis_designsystem
IF EXISTS (SELECT name FROM sysobjects
where name = 'proc_tGuideLimit' AND type = 'P')
drop procedure proc_tGuideLimit
GO Create procedure proc_tGuideLimit
@teacher_work_id char(10),
@flag tinyint output
as
Declare @curr_num int,
@max_num int
select @curr_num=count(teacher_work_id),
@max_num=max_guide
from Thesis_choose_result T join Give_guide_limit G on T.teacher_work_id=G.teacher_work_id
where T.teacher_work_id=@teacher_work_id
If (@max_num - @curr_num)>0
set @flag=1
else
set @flag=0
Go