SQL存储过程选择仅返回没有值的表

时间:2016-05-23 06:30:12

标签: sql sql-server stored-procedures

我的带有select的SQL存储过程只返回没有值的表,它只显示没有任何值的列名吗?为什么?如何使用存储过程检索表的值?

 [1]: http://i.stack.imgur.com/79Gt2.jpg
USE [Mobile]
GO
/****** Object:  StoredProcedure [dbo].[UserRegisterproc]    Script Date: 05/23/2016 10:51:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[UserRegisterproc]
@mode int=null,
@id int=null,
@name varchar(30)=null,
@usertype varchar(30)=null,
@username varchar(30),
@password varchar(30),
@email varchar(30)=null,
@mob varchar(30)=null
as begin
if (@mode =1) 
begin
insert into UserRegister (name,usertype,username,password ,email,mob )values(@name,@usertype,@username,@password ,@email,@mob )
end
if(@mode =2) 
begin
select * from UserRegister 
end
if (@mode =3) 
begin
update UserRegister  set name=@name,usertype=@usertype,password=@password ,email=@email,mob=@mob where username=@username
end
if(@mode =4) 
begin
delete from UserRegister where username=@username
end
if(@mode =5) 
begin
  select * from UserRegister where username =@username and password =@password 
  end
if(@mode =6) 
begin
  select * from UserRegister where usertype= @usertype
  end
  if(@mode =7) 
begin
  select * from UserRegister where usertype  =@usertype  and username =@username 
  end
end

1 个答案:

答案 0 :(得分:1)

1)尝试运行

select * from UserRegister  确保表格有数据

如果数据存在

2)你应该尝试用
运行 select * from UserRegister where usertype ='abc' and username ='abc'

abc 是来自UserRegister表的实际数据