Sql-server – AlwaysEncrypted Conversion Fails

always-encryptedsql serversql-server-2016

I'm trying to encrypt a column with AlwaysEncrypted and I get the following error.

Could not deploy package.

Warning SQL72012: The object [AlwaysEncryptedDemo] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.

Warning SQL72012: The object [AlwaysEncryptedDemo_log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.

Warning SQL72015: The table [dbo].[tmp_ms_xx_t1] is being dropped, data loss could occur.

Error SQL72014: .Net SqlClient Data Provider: Msg 50000, Level 16, State 127, Line 6 Rows were detected. The schema update is terminating because data loss might occur.

Error SQL72045: Script execution error.

The executed script:

IF EXISTS (SELECT TOP 1 1
           FROM   [dbo].[tmp_ms_xx_t1])
    RAISERROR (N'Rows were detected. The schema update is terminating' +
          ' because data loss might occur.', 16, 127)
        WITH NOWAIT;

This happens both in SSMS and using the generated PowerShell. The table schema is simply one column, nvarchar(10). We're only testing this out.

Can someone help me get past this error please?

Best Answer

So, this actually wasn't a bug. There is (was) a trigger on the table that was changing data. The changing data is what caused the conversion to fail. Disabling the trigger did not help, it had to be dropped.