How to encrypt a column in MSSQL

Posted on Updated on

When creating a table, there may be a need to set encryption for a specific column.  Let us say you create a logins table with columns for username and password.  Most likely, you would want the password column to be encrypted so it won’t be visible to anybody that has access to the database.


Here is one way you can enable encryption:

1.  First you have to set the data type of the column to varbinary(100) or (max)

2.  Next, is you can add the function PWDENCRYPT in your T-SQL script


update employees.dbo.logins

set password = (PWDENCRYPT(‘Password Here’))

where employeeid = 1


Once you commit the changes, your password value will be converted to something similar to 0x0200635…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s