Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Password History Table Expand / Collapse
Author
Message
Posted Wednesday, May 7, 2014 4:18 PM This worked for the OP Answer marked as solution


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 4:10 PM
Points: 3,645, Visits: 7,955
I know that this might not be constructive, but I had to ask.
Why do you want that security measure to avoid repeated passwords, but you limit your passwords to 10 characters and store them in plain text? Would it be just to give you a false security?

To avoid being useless, I guess that you were after something like this, but remember that keeping your system the way it is now, might cause security/privacy issues:

CREATE TABLE #Password_His
(
playerid int not null,
password nchar(10) not null,
PasswordDate datetime
);

INSERT #Password_His
VALUES( 1, 'Password01', GETDATE() - 11),
( 2, 'Password02', GETDATE() - 10),
( 3, 'Password03', GETDATE() - 9),
( 4, 'Password04', GETDATE() - 8),
( 5, 'Password05', GETDATE() - 7),
( 6, 'Password06', GETDATE() - 6),
( 7, 'Password07', GETDATE() - 5),
( 8, 'Password08', GETDATE() - 4),
( 9, 'Password09', GETDATE() - 3),
( 10, 'Password10', GETDATE() - 2),
( 11, 'Password11', GETDATE() - 1);

DECLARE @Exists bit = 0,
@Password nchar(10) = 'Password04';

SELECT @Exists = 1
FROM (
SELECT TOP 10 [password]
FROM #Password_His
ORDER BY PasswordDate DESC)x
WHERE [password] = @Password;

SELECT @Exists;

GO
DROP TABLE #Password_His;




Luis C.
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1568727
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse