Sql-server – Error 71501, 71561 while encrypting columns using always encrypted feature of SQL Server 2016

always-encryptedsql serversql-server-2016

1) I am trying to encrypt some varchar columns which are not identity / primary using the always encrypted feature of SQL Server 2016,
but getting an error code 71501,71561 for unresolved and / or ambiguous reference.

How do I resolve this ?

2) Is there a way to nominate a column as primary key for all tables at once ,which do not have a Primary Key .

Thanks

Best Answer

Regarding your first question, which version of SSMS, are you using? If it's older than 17.0, I recommend trying the newest version (https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms).

Based on your description, I suspect you are using SSMS 16.x. The likely root cause of this problem is that the objects in your database have external dependencies (on objects in other databases) or have broken dependencies. In SSMS 16.x, the Always Encrypted wizard does a comprehensive validation of all dependencies in the entire database, including objects not dependent on that tables that you are trying to encrypt. We have fixed this problem in SSMS 17, by limiting the validation only to the tables containing the columns you are encrypting and the wizard does not error out anymore when encountering a validation error. Instead, it completes encryption and produces a warning, allowing you to investigate/address the issue later.

Regarding your second question - you need to designate a primary key column for each table.