SQL querry of the non-latin characters without N prefix

We are able to querry texts including non-latin characters (like; Turkish, Chineese, Russian..etc) in Where conditions with the help of N prefix or nvarchar cast operations via SQL as below ;

SELECT *  FROM DBNAME..TABLENAME  WHERE COLUMNNAME LIKE N'%Şikayet%' 

But how to querry if we are using a variable (in a function, procedure..etc) ? With the help of varbinary casting operation we can querry with success;



DECLARE @VARIABLE NVARCHAR(MAX)
SET @VARIABLE='Şikayet'

SELECT *  FROM DBNAME..TABLENAME  WHERE CAST(COLUMNNAME AS varbinary(10)) LIKE CAST(@VARIABLE AS varbinary(10)) 

No comments:

© 2011-2015 | EmreCiftci.net. Powered by Blogger.