Click here to Skip to main content
15,889,440 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to write a select statement in store procedure and get the value of two fields of a table Login_table?

In database a table Registration with following fields,
ID
Name
Email_ID
Pass
and i want a registered user must login into site therefore how to write query for login using storeprocedure?

help me
Posted
Updated 28-Mar-13 4:17am
v2
Comments
[no name] 28-Mar-13 9:58am    
ALTER PROCEDURE LogIn
AS
SELECT * FROM Login_Table;
RETURN
[no name] 28-Mar-13 10:00am    
What have you tried?
"login through Write Query" makes no sense at all
What is the problem? Writing a SELECT query? Writing a stored procedure?
deepak Singh m 28-Mar-13 10:12am    
ALTER PROCEDURE Login
(
@Email_ID varchar(50),
@Pass varchar(50)
)

AS
select @Email_ID,@Pass=Pass from Registration
RETURN



Not Working,i want value of Emil_ID And password Field of table Login??
[no name] 28-Mar-13 10:28am    
Not working is not helpful. If you want information from the Login table why are you querying the Registration table? Your query would not work anyway. SELECT Email_ID, Pass FROM Login WHERE Email_ID=@Email_ID AND Pass=@Pass.

Hello,

try following proc.
SQL
ALTER PROCEDURE Login
(
    @Email_ID VARCHAR(50) OUTPUT,
    @Pass VARCHAR(50) OUTPUT
)
AS
    SELECT @Email_ID = Email_Id, @Pass = Pass FROM Registration
RETURN

Note: You will have to have where condition which will ensure that a single record gets selected.

Regards,
 
Share this answer
 
v2
SQL
CREATE PROCEDURE Login
( 
  @Email_ID   NVARCHAR (50),
  @Pass       NVARCHAR (50)
)

AS 
BEGIN

SET NOCOUNT ON

SELECT * 
FROM Registration
WHERE Email_ID = @Email_ID 
  AND pass = @pass COLLATE SQL_Latin1_General_CP1_CS_AS -- this makes it a case sensitive match

END


Then just replace SELECT * with whatever fields you need to have come back.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900