how to encrypt a column with a key (SQL 2012)

I have created a Certificate and a symmetric key, in this user database. How exactly should encryption of the column happen so that no one can just do a SELECT to read the data without knowing the symmetric key (making the data secure)?

in the below example,
FirstColumn  should not be readable by anyone.

   create table test (FirstColumn int)
 insert into test select 1111
 select * from test --displays int
 alter table test alter column FirstColumn varbinary(10)  
 select * from test --displays binary
 SELECT CAST(FirstColumn as int),FirstColumn from test
 alter table test alter column FirstColumn int
 select * from test --displays int
 drop table test
LVL 5
25112Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Neil RussellTechnical Development LeadCommented:
You have missed the point of how this works.
There is a complete example on mssqltips Dot Com that has clear step by step instructions on how to do this.
In short the steps involved are far more complex than you seem to think.  The data is stored in an encrypted format and doing a simple select will only return the encrypted data and that will mean nothing to anybody.

You need to add a new field to hold your encrypted data, created using EncryptByKey() passing in your symetric key and your plain data.

Then you can delete the column with your plain data in it and the encrypted data can only be read using, in unencrypted form, using DecryptByKey() passing in your encrypted field data.

Have a look at the full article and you will be flying. Simple and easy to follow.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.