Password Encryption and Decrypt

How to Encrypt Password and compare?

MS SQL has its own built in function to Encrypt password or secure text and compare it. This is very simple see the Example:

—1 , Create a Table to insert.

Create table tempPassTable
id int,
pwd varbinary(200)

—2, Insert encrypted value to a table.

insert into tempPassTable(id,pwd)
select 1, pwdencrypt('abcd')

—3, Compare encrypted value and user input value.

if (select pwdcompare('abcd',pwd,0) from tempPassTable)=0 
select 'Invalid Password'
select 'Valid Password'