SQLTeam.com | Weblogs | Forums

Fetching Data from DB using encrypted field in SQL query

I am trying to work on a query to fetch data using encrypted field name .

say the field Name is (Always encrypted).

I am able to get data like this :

SELECT [Name]=105,CONVERT(int, DecryptByKey('ColumnKey'))
FROM [sampleuser].[dbo].[SmUser];

[Name field in an integer]

But I am looking for a query with the format:

SELECT * FROM WHERE Name = 105

I tried something like this

SELECT * FROM .[dbo].[SmUser] WHERE [Name]=105, CONVERT(int, DecryptByKey('ColumnKey'));

But this gives error.
Line 24, column 47
Incorrect syntax near ,.

Any pointers how this can be achieved .

--Sangram

Welcome

Which columkey is being decrypted?
I doubt it is Name as it seems to be a varchar field.

SELECT * 
  FROM .[dbo].[SmUser] 
 WHERE CONVERT(int, DecryptByKey([Name])) = 105

Blockquote