2016-05-23 6 views
0

selectを使用したSQLストアドプロシージャでは、値のないテーブルのみが返されます。どうして?どのようにストアドプロシージャを使用してテーブルの値を取得するには?SQLストアドプロシージャselectは値のないテーブルのみを返します

[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 [email protected],[email protected],[email protected] ,[email protected],[email protected] where [email protected] 
end 
if(@mode =4) 
begin 
delete from UserRegister where [email protected] 
end 
if(@mode =5) 
begin 
    select * from UserRegister where username [email protected] and password [email protected] 
    end 
if(@mode =6) 
begin 
    select * from UserRegister where usertype= @usertype 
    end 
    if(@mode =7) 
begin 
    select * from UserRegister where usertype [email protected] and username [email protected] 
    end 
end 
+2

SPで使用されたクエリでは、その理由が返されませんでした。 SPを投稿してください。 –

+2

私たちに推測してもらいたいですか? – sagi

+0

答えを編集して、適切な形式で追加してください。 – sagi

答えて

1

1)は、データが存在する場合は必ず表が

データ

を持たせるために

select * from UserRegister を実行しよう

2)あなたが使用して実行してみてください
select * from UserRegister where usertype ='abc' and username ='abc'

abcは本当ですUserRegisterテーブルのデータ

関連する問題