Supposons qu'il ya une table nommée "myTable" avec trois colonnes:Weird SQL Behavior, pourquoi cette requête ne renvoie rien?
{**ID**(PK, int, not null),
**X**(PK, int, not null),
**Name**(nvarchar(256), not null)}.
Soit {4, 1, аккаунт} un dossier sur la table.
select * from myTable as t
where t.ID=4
AND t.X = 1
AND ( t.Name = N'аккаунт' )
select * from myTable as t
where t.ID=4
AND t.X = 1
AND ( t.Name LIKE N'%аккаунт%' )
La première requête renvoie l'enregistrement, mais pas la seconde? Pourquoi?
systèmes où ces problèmes sont expérimentés:
* Windows XP - Professional - Version 2002 - SP3
serveur Collation: Latin1_General_CI_AS
Version: 9.00.3073.00
Niveau: SP2
Édition: Developer Edition
Sever Collation: SQL_Latin1_General_CP1_CI_AS
Version: 9.00.3054.00
Niveau: SP2
Édition: Enterprise Edition
Résultats:
SELECT SERVERPROPERTY('SQLCharSetName')
iso_1
Using OSQL.exe
0x30043A043A04300443043D04420400000000000000000000000000000000
0x3F3F3F3F3F3F3F0000000000000000000000000000000000000000000000
0x253F3F3F3F3F3F3F25000000000000000000000000000000000000000000
SELECT CAST(name AS BINARY),
CAST(N'аккаунт' AS BINARY),
CAST(N'%аккаунт%' AS BINARY)
FROM myTable t
WHERE t.ID = 4
AND t.X = 1
CAST(name AS BINARY)
0x30043A043A04300443043D04420400000000000000000000000000000000
CAST(N'аккаунт' AS BINARY)
0x3F3F3F3F3F3F3F0000000000000000000000000000000000000000000000
CAST(N'%аккаунт%' AS BINARY)
0x253F3F3F3F3F3F3F25000000000000000000000000000000000000000000
Ce résultat est attendu. @ Le littéral cyrillique de Newbie est converti en points d'interrogation, il a probablement quelques problèmes avec l'encodage du côté client. – Quassnoi
Pourriez-vous indiquer la version du serveur SQL que vous utilisez? Merci! – Newbie