Possible Duplicates:
encryption/decryption all the columns in the table
how do you encrypt an entire SQL 2005 database?
I want to encrypt and decrypt the all columns in the table.
and also i dont want to use TDE(Transparent Data Encryption).
With the following i m able to encrypt/decrypt only one column in the table.
CREATE MASTER KEY ENCRYPTION BY
PASSWORD='LORD'
CREATE CERTIFICATE ENCDECTEST
WITH SUBJECT='LORD'
SELECT * FROM SYS.CERTIFICATES
CREATE SYMMETRIC KEY TESTKEY
WITH ALGORITHM=TRIPLE_DES
ENCRYPTION BY CERTIFICATE ENCDECTEST
--Sample table
CREATE TABLE USERS
(UID INT IDENTITY(100,1),
UFNAME VARCHAR(100),
ULNAME VARCHAR(100),
ULOGINDI VARCHAR(50),
UPASSWORD VARBINARY(256))
Procedure to Insert Data in Table
ALTER PROC [InsertUSER]
@UFNAME VARCHAR(100),
@ULNAME VARCHAR(100),
@ULOGINDI VARCHAR(12),
@UPASSWORD VARCHAR(20)
AS
BEGIN
opening the key as it is not already
OPEN SYMMETRIC KEY TESTKEY
DECRYPTION BY CERTIFICATE ENCDECTEST;
-- Insert statement
INSERT INTO [USERS]
(UFNAME, ULNAME, ULOGINDI, UPASSWORD)
VALUES
(@UFNAME, @ULNAME, @ULOGINDI,
EncryptByKey(Key_GUID('TESTKEY'), @UPASSWORD));
END;
--Insert Procedure
EXEC INSERTUSER 'Koti','Routhu','Koti_J_Routhu','GloryToLORD'
-- Procedure to Retrive Users
CREATE PROC [RetrieveUSER] @UID INT
AS
BEGIN
-- open the key as it is not already
OPEN SYMMETRIC KEY TESTKEY
DECRYPTION BY CERTIFICATE ENCDECTEST;
-- Select statement
SELECT UID,
UFNAME,
ULNAME,
ULOGINDI,
CONVERT(VARCHAR(20),DECRYPTBYKEY(UPASSWORD)) AS PASSWORD
FROM USERS WHERE UID = @UID;
END;
-- Execute Retrive Procedure
EXEC RetrieveUSER 100
With the above i m able to encrpt/decrypt only "UPASSWORD" column only.I want to encrypt/decrypt all the columns in the table.
Please help me in this regard.
Thank you.
asked
Mar 14 '10 at 09:16 AM
in Default
kotiRouthu
22
●
2
●
2
●
2
Can you please remember to format any code in your questions to assist others in reading your question and then helping you. You simply highlight the code section and press the 'code' button in the text editing toolbar. Thanks!
I voted to close this because it is virtually identical the your previous question. I added the "not TDE" part to the other question.
can you explain why you dont want to use TDE please?