SQL Server search in nvarchar & ntext

后端 未结 3 1840
面向向阳花
面向向阳花 2021-01-05 16:40

I\'m using SQL Server 2008 as my database engine in a VS2010, C# ASP.NET web app. My project is Farsi (Persian) so I\'ve used nvarchar and ntext as

相关标签:
3条回答
  • 2021-01-05 16:40

    You must use COLLATE Latin1_General_BIN2 to get results. Works for Amharic for Ethiopians.

    Select * From YourTableName where ColNameYouSearch LIKE N'%YourSerchCriteria%' COLLATE Latin1_General_BIN2"
    
    0 讨论(0)
  • 2021-01-05 16:41

    I am not familiar with C# ASP.NET, but using nvarchar or ntext shouldn't make any difference in query type. I am wandering you are only assigning your query command to a variable and not executing it.. should you do something like myCommand.execute() ?

    0 讨论(0)
  • 2021-01-05 16:52

    You should use the N' prefix to indicate that you're searching for a Unicode string:

    SELECT * FROM dbo.tblArticle WHERE name LIKE N'%......%'
    

    Otherwise, you're converting your search string back to non-Unicode and then searching....

    0 讨论(0)
提交回复
热议问题