0

Possible Duplicate:
Extended ascii characters search in SQL Server

I have table in SQL Server where data may be stored with extended charcaters (♥,♣,♦...) in one of the column.

From my .net database layer, the string is passed in encoded format to the database.

There is column Name in the DB and has value santosh♥.

Now from my .net code, I will pass 'santosh♥' as '%E2%99%A5' (encoded value for santosh♥). So now DB has to search for santosh♥ in the column Name by using '%E2%99%A5' string.

For ex:

select * from table where Name='%E2%99%A5';

but the above query doesn't work.

Any help?

Community
  • 1
  • 1
Santosh
  • 2,355
  • 10
  • 41
  • 64
  • Is there anyway where i can convert 'santosh♥' to '%E2%99%A5' and vice versa in DB.My question here is to pass the value as it is and interchange in DB. – Santosh Oct 22 '12 at 07:31
  • Why are you even encoding this value at all? Just create an ADO.NET query that takes a **parameter** of `SqlDbType.NVarChar` and you're done. You're overthinking and over-engineering the solution to this problem.... unfortunately, you didn't show us your **C# code** to start this search.... – marc_s Oct 22 '12 at 07:40
  • I cant change the datatype now.The column value is varchar and it will be varchar only.So is there a possibility of keeping the datatype same and search by encoding/decoding the value at DB level. – Santosh Oct 22 '12 at 07:46
  • 1
    Yes, the **parameter** for your query must be `SqlDbType.NVarChar` (not the database column per se) – marc_s Oct 22 '12 at 08:00

0 Answers0