declare @pass varbinary(256)select @pass=pwdencrypt('lsok')select @passselect pwdcompare('lsok',@pass)如果pwdcompare返回1﹐表示口令正確﹐等于0則不正確。说明:pwdencrypt是加密函数,pwdCompare是比较函数返回1表示相等。
這里有一點要注意的是:pwdencrypt返回的數據類型是varbinary(256)
所以如果想使用pwdencrypt函數加密用戶密碼的話,則密碼欄位的數據類型一定要是varbinary(256) .否則在使用pwdcompare函數時,會出現錯誤.