SQLserver存储器的问题 高分求解

来源:百度知道 编辑:UC知道 时间:2024/05/22 16:58:53
create proc stu
(
@sxh int,
@spass varchar(10),
@count int output
)
as
select @count=count(*) from student where sxh=@sxh and spass=@spass
GO
//执行
declare @count int
exec st 2003403202,2003403202, @count output
select 'wo'=@count

//,执行后返回的是1.
将存储过程换为:
create proc st
(
@snm varchar,
@spass varchar(10),
@count int output
)
as
select @count=count(*) from student where snm=@snm and spass=@spass
GO
//执行:

declare @count int
exec st xhy,2003403202, @count output
select 'wo'=@count
返回的是0
而记录是相同的一条,且其中上午数据类型我都仔细对过无误,只是中间换了一个参数,确的到不同的结果,奇怪啊???高手能否看看,高分回报!!!!!
问题已经找到了,不是出在这上面,出在另一个方面,不过还是很感谢你的关注,故采纳问答案.分奖你,以谢关注.....

一点也不奇怪,sxh=@sxh and spass=@spass 和 snm=@snm and spass=@spass 是完全不同的两个条件

改成这样试一下

create proc st
(
@snm varchar(10),
@spass varchar(10),
@count int output
)
as
select @count=count(*) from student where snm=@snm and spass=@spass
GO
//执行:

declare @count int
exec st 'xhy','2003403202', @count output
select 'wo'=@count

补充:
你自己好好看看一样不一样,snm列值是"xhy"这一行对应的sxh列值是不是2003403202?
看懂我第一句话没?