--pwdencrypt ,pwdcompare
CREATE TABLE Users
(
UserID VARCHAR(10) ,
UserPW VARBINARY(256)
)
INSERT INTO USERS
VALUES ( 'TestUser1', pwdencrypt('TestPW1') )
INSERT INTO USERS
VALUES ( 'TestUser2', pwdencrypt('TestPW1') )
INSERT INTO USERS
VALUES ( 'TestUser3', pwdencrypt('TestPW1') )
INSERT INTO USERS
VALUES ( 'TestUser4', pwdencrypt('TestPW1') )
SELECT *
FROM USERS
/*
UserID UserPW
TestUser1 0x010019F4E1B1838CA7DF3B27A02B85FB7F9A67C5639CA5FE35E9
TestUser2 0x010073F6B62F8DBEDCB1047DF8A337F78568FA75F57A8AC53CB1
TestUser3 0x01009E7786D6EC436FD0CD6206C864DEA946E952C6E5CF87D954
TestUser4 0x01004D5A946E07E9C55CEEE4441DCD9390A3850FA0A008055728
*/
DECLARE @pwd VARBINARY(256)
SELECT @pwd = UserPW
FROM USERS
WHERE UserID = 'TestUser1'
SELECT @pwd
SELECT pwdcompare('TestPW1', @pwd)
--pwdcompare(密码,@pwd)
IF pwdcompare('TestPW1', @pwd) = 1
PRINT '密码正确'
ELSE
PRINT '密码错误'
--delete USERS