存储过程返回值的问题?会的教教我啊,在线等,解决就散分
在存储过程中当select语句成功查询出一条记录时就返回1,否则返回0
Set Nocount on
if Exists(
select * from admin where userName=@username and userPass=@pwd
)
begin
set @rows=1
return
end
else
begin
set @rows=0
return
end
Set Nocount off
但是insert,update,delete语句像上面那样就会报错
Set Nocount on
if Exists(
delete from news where n_Id=@newsId
begin
set @rows=1
return
end
else
begin
set @rows=0
return
end
Set Nocount off
正确写法应该是怎样的?
------解决方案--------------------建议发到 数据库开发 ms sqlserver 版。那里回贴速度超快
------解决方案--------------------select * from admin where userName=@username and userPass=@pwd
if @@rowcount> 1
select @row=1
else
select @row=0
用delete、update同样有效
------解决方案--------------------create proc aa(@username nvarchar(50),@pwd nvarchar(20))
as
declare @flag int
select @flag=count(*) from admin where userName=@username and userPass=@pwd
if(@flag=1)
return 1
else
return 0