2017-05-29 1 views
3

J'ai créé une table à l'aide:SQL Server 2016 - Est-il possible de concaténer deux colonnes toujours cryptées nvarchar?

create table dbo.employee(firstname nvarchar(100) null,lastname nvarchar(100) null) 

Inséré des données échantillon à l'aide:

insert into dbo.employee values('Sachin','Tendulkar') 
insert into dbo.employee values('Rohit','Sharma') 
insert into dbo.employee values('Virendra','Sehwag') 
insert into dbo.employee values('Irfan','Pathan') 

J'ai ensuite utilisé toujours Assistant crypté pour crypter les deux colonnes de ce tableau à l'aide SSMS v17. Et maintenant, je suis en train de concaténer prenom avec nom comme celui-ci:

select concat(firstname, lastname) from dbo.employee 

Et il me donne ci-dessous erreur:

Operand type clash: nvarchar(100) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'SampleDB_CEK', column_encryption_key_database_name = 'SampleDB') is incompatible with varchar

Quand j'essaie ceci:

select firstname + lastname from dbo.employee 

Il donne suite erreur:

Encryption scheme mismatch for columns/variables 'firstname', 'lastname'. The encryption scheme for the columns/variables is (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'SampleDB_CEK', column_encryption_key_database_name = 'SampleDB') and the expression near line '1' expects it to be (encryption_type = 'PLAINTEXT') (or weaker).

Toute aide appréciée.

+0

s'y attend à être (encryption_type = 'PLAINTEXT') (ou plus faible). Cette information n'est-elle pas suffisante? – user6144226

Répondre

3

La concaténation n'est pas autorisée sur les colonnes chiffrées. Actuellement, la seule opération possible sur les colonnes cryptées est l'égalité. Cela est dû au fait que SQL Server n'a pas la clé.

Vous devrez peut-être implémenter cette logique dans l'application cliente.

De la documentation officielle

Deterministic encryption always generates the same encrypted value for any given plain text value. Using deterministic encryption allows point lookups, equality joins, grouping and indexing on encrypted columns. However, but may also allow unauthorized users to guess information about encrypted values by examining patterns in the encrypted column, especially if there is a small set of possible encrypted values, such as True/False, or North/South/East/West region. Deterministic encryption must use a column collation with a binary2 sort order for character columns.

Randomized encryption uses a method that encrypts data in a less predictable manner. Randomized encryption is more secure, but prevents searching, grouping, indexing, and joining on encrypted columns.