How to remove Always Encrypted from a column in SQL Server 2016

╄→尐↘猪︶ㄣ 提交于 2020-05-14 19:12:54

问题


How can I remove the encryption property from a column in SQL Server 2016?

I've enabled this feature using the Always Encrypted wizard in SQL Server Management Studio 2016, but I would like to remove the encryption from some columns I've added before.

I wonder if the following 2 things are possible (and if so how?):

  1. Really undo the encryption using the certificate used for the encryption.
  2. Remove the encryption and leave the encrypted data in the cells.

回答1:


The answer for question 1) is to run the Always Encrypted wizard again and select "Plaintext" as Encryption Type.

Side note: I had to remove a default value constraint on a bit column to make the wizard complete without errors.




回答2:


The above recommendation is a little simplistic and may set you up for problems down the road. First enabling Always Encrypted on a Column will change the collation of that column to one of the Binary2 Collations and moving back to cleartext does not return the column to the correct collation. If you try some comparisons you may get collation issues. Next you have left the Master key and Encryption keys. Maybe you want to keep them maybe not. But be prepared for strange errors like Msg 8180, Level 16, State 1, Procedure sp_describe_parameter_encryption, Line 1 [Batch Start Line 0] Statement(s) could not be prepared. If you don't want Always Encrypted get rid of all of it not just the visible piece. I got that error from a server that has Always Encrypted enabled on a database. But I wasn't working on that database. The database I was working on had no encryption enabled.




回答3:


You should also check your tempdb. Is it encrypted e.g. Select is_encrypted from sys.databases.



来源:https://stackoverflow.com/questions/43878655/how-to-remove-always-encrypted-from-a-column-in-sql-server-2016

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!