create proc function_search_free
@train_no char(5),@date date,@start_station varchar(50),@end_station varchar(50),@seat_free_num int output
as
declare @start_time time(0),@arrive_time time(0)
exec function_search_free2 '@train_no','@date','@start_station','@end_station',@start_time out,@arrive_time out
select @seat_free_num=(select count(*)
from view_buy_info b
where train_no=@train_no and train_date=@date and ((@start_time between start_time and arrive_time) or (@arrive_time between start_time and arrive_time))
)
create proc function_search_free2
@train_no char(5),@date date,@start_station varchar(50),@end_station varchar(50),@start_time time(0) output,@end_time time(0) output
as
select @start_time=start_time,@end_time=arrive_time
from view_buy_info
where Train_no=@train_no and @start_station=Startstation_name and @end_station=Endstation_name and @date=train_date
各位大大,我现在创建了两个存储过程,期间有存储过程的调用,然后现在我执行
declare @sum int
exec function_search_free 'G0001','2012-01-01','上海','苏州',@sum out
print @sum
结果显示:消息 8114,级别 16,状态 1,过程 function_search_free2,第 0 行
从数据类型 varchar 转换为 date 时出错。
看了很久不明白啊、我哪里有varchar向date的转化?
难道说存储过程调用的时候默认是把所有的参数转化为varchar吗?
希望各位帮忙解答!