TomThomson (7/19/2014)
Welsh Corgi (7/18/2014)
I'm having a weird problem.I do not have it in one AS400 Library within SSIS but when I go to another I get an error that the column does not exist. The column exist.
[/
[Execute SQL Task] Error: Executing the query "IF NOT EXISTS (SELECT * FROM sys.symmetric_keys WH..." failed with the following error: "Invalid column name 'ENCR_TAX_ID_NUMBER'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
quote]
I execute the code in SSMS and no errors.
IF NOT EXISTS (SELECT * FROM sys.symmetric_keys WHERE name = 'AES257SecureSymmetricKey')
BEGIN
CREATE SYMMETRIC KEY AES257SecureSymmetricKey
WITH ALGORITHM = AES_256
ENCRYPTION BY PASSWORD = N'StrongP@ssw0rd!';
END
OPEN SYMMETRIC KEY AES257SecureSymmetricKey
DECRYPTION BY PASSWORD = N'StrongP@ssw0rd!';
UPDATE POINT_CYP.AGENT_SUPPORT
SET ENCR_TAX_ID_NUMBER = EncryptByKey(Key_GUID('AES257SecureSymmetricKey'), convert(varbinary(68), TAX_ID_NUMBER))
,TAX_ID_NUMBER = '**********';
CLOSE SYMMETRIC KEY AES257SecureSymmetricKey;
No comprede?
The failing code you've quoted doesn't show the where clause. So I can't be certain what is happening. But it looks as if you have managed to write a where clause which refers to a column in the table POINT_CYP.AGENT_SUPPORT when the FROM clause refers only to the view sys.symmetric_keys. Perhaps a copy and paste accidentally from the wrong place?
I should have provided more information.
Now I can't get it to work in SSMS. It encrypts but it does not decrypt. The Plain Text returns ******.
SELECT
PRIMARY_ACCOUNT_NAME
,CONVERT(varchar(128), DecryptByKey(ENCR_TAX_ID_NUMBER)) as Plaintext_TAX_ID_NUMBER
,DATALENGTH(ENCR_TAX_ID_NUMBER) AS D_LEN
FROM POINT_CTL.AGENT_SUPPORT;
The code that you provided still works.
I'm not giving you enough information.
:unsure:
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/