Re: Difference between constant and a variable - Sql SP and Unicode
From: Steve Kass (skass_at_drew.edu)
Date: 12/29/04
- Next message: Aaron [SQL Server MVP]: "Re: Selecting"
- Previous message: Oleg Ogurok: "Re: KB 322884, SQL2000 and COM Interop"
- In reply to: Jeff Sabado: "Difference between constant and a variable - Sql SP and Unicode"
- Messages sorted by: [ date ] [ thread ]
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!
>
>
>
- Next message: Aaron [SQL Server MVP]: "Re: Selecting"
- Previous message: Oleg Ogurok: "Re: KB 322884, SQL2000 and COM Interop"
- In reply to: Jeff Sabado: "Difference between constant and a variable - Sql SP and Unicode"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|