Eben Varghese Paul
Eben Varghese Paul

Reputation: 21

SQL Stored Procedure select returns only table without values

My SQL stored procedure with select returns only table without values,it just shows the column name without any values in it ? Why? How to retrieve values of the table using stored procedure?

 [1]: https://i.sstatic.net/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

Upvotes: 0

Views: 145

Answers (1)

Myo Myint Aung
Myo Myint Aung

Reputation: 147

1) try to run

select * from UserRegister to make sure table have data

if data exists

2) You should try to run with
select * from UserRegister where usertype ='abc' and username ='abc'

abc is real data from UserRegister table

Upvotes: 1

Related Questions