SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Get Number of Row which contains text
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

doctorzeus
Starting Member

1 Posts

Posted - 07/21/2013 :  08:18:58  Show Profile  Reply with Quote
Hello,

The title pretty much explains what I am trying to achieve, basically I have to columns; One contains "Username" and the other contains "Password".

I am trying to create a query that checks the username column for a specific value and then if it is found returns the row number so it can be checked against the password..

I am fairly new to SQL so if there is a better way of doing this please feel free to make suggestions (keeping in mind the database is being queried from a asp.net web service)..

Many Thanks

DoctorZeus

SwePeso
Patron Saint of Lost Yaks

Sweden
29910 Posts

Posted - 07/21/2013 :  09:37:56  Show Profile  Visit SwePeso's Homepage  Reply with Quote
You are doing the completely wrong. The password should be hashed with SHA1/2 (at least with MD5) and perhaps even salted.
Then you query the table if BOTH the password and the hashed password match. If they do, then you act upon that.
If there is no match, then you act upon that.

Never ever store passwords in clear text in a database.


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

MuMu88
Aged Yak Warrior

547 Posts

Posted - 07/21/2013 :  09:39:04  Show Profile  Reply with Quote
I am not sure why you want to get row number, but here is a way to get the password given the user name:


-- TEST DATA 
DECLARE @MyTable TABLE (UserName VARCHAR(10), [Password] VARCHAR(10));
INSERT INTO @MyTable VALUES
('John', 'Giotto'),
('James', 'Aryabhata'),
('George', 'Sagan'),
('Mary', 'Picard'),
('Rama', 'Kepler'),
('Victor', 'Tatyana');

-- RETURN PASSWORD
SELECT [Password] from @MyTable where UserName = 'James';





Edited by - MuMu88 on 07/21/2013 10:11:47
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000