Re: Difference between constant and a variable - Sql SP and Unicode

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Steve Kass (skass_at_drew.edu)
Date: 12/29/04


Date: Wed, 29 Dec 2004 17:34:49 -0500

Jeff,

There are two problems here.
  1. Use nvarchar, not nchar, unless you mean to match only fieldName
values ending in 35 space characters...
  2. Specify the search string as a Unicode string literal, by prefixing
it with N.

In other words:

DECLARE @searchText nvarchar(40) -- now nvarchar
SET @searchText = N'%荷商荷%' -- now a Unicode literal
SELECT * FROM tableName WHERE fieldName LIKE @searchText

Steve Kass
Drew University

Jeff Sabado wrote:

>Making my first attempt at querying a SQL field which contains Chinese
>characters... in initial testing, I found that I could do a simple wild card
>query, just as I might for standard Arabic characters:
>
>SELECT * FROM tableName WHERE fieldName LIKE '%荷商荷%'
>
>I'm hoping to use a stored procedure, and pass the user's input from a web
>page to it to search for potential matching records. But when I declare the
>search string above as a variable, the select statement no longer works.
>
>DECLARE @searchText nchar(40)
>SET @searchText = '%荷商荷%'
>SELECT * FROM tableName WHERE fieldName LIKE @searchText
>
>I've set the collation name on the database = "Chinese_Taiwan_Bopomofo_BIN",
>and the field I'm querying also has the same collation setting. Any input
>would be much appreciated!
>
>
>



Relevant Pages

  • Re: Dynamic text color
    ... of the characters between quotes are to be colored. ... but you've decided that you really want this similar regexp search string: ... You can achieve this by transforming each item on the list, then invoking joinon the transformed list to create the search string. ...
    (comp.lang.python)
  • Re: field properties in queries - "description" even though description ent
    ... Dim rs As Recordset ... - The fieldname for this checkbox has 55 characters ...
    (microsoft.public.access.modulesdaovba)
  • Re: Parsing Binary Files
    ... I was able to get proper matches. ... Well, you could supply multiple byte arrays, and check whether the nth ... > of characters after that search and display it. ... > I would know it because it will truncate with another search string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: best language for text string search
    ... I'm going to have a maximum input of ~6million characters (normally ... The search string is going to maximum 30 characters ... I also thought that there would be a more suitable language to use ...
    (comp.programming)
  • Re: best language for text string search
    ... The search string is going to maximum 30 characters ... Here's an example in Python. ... for key in keys: ...
    (comp.programming)