在SQL查询和表格名称中使用带有重音符号的字符 [英] Working with characters with accents in sql query and table name
问题描述
我正在做一些php&数据库中的SQL Server 2005,在表名,列名和字段中都带有重音符号(é,è,à).不幸的是,我不是该数据库的所有者/创建者,但我同意必须对该所有者打耳光:).
I'm doing some php & SQL Server 2005 in a database with accents ( é , è , à ) in both tables names , columns names and fields . Unfortunately , I'm not the owner/creator of this database , but I agree that the owner must be slapped :) .
我正在使用ODBC驱动程序连接到SQL Server odbc_connect($dsn,$user,$password)
.
Im using ODBC driver to connect to the SQL Server odbc_connect($dsn,$user,$password)
.
我的问题是,每个带有重音符号的字段都无法识别. 例如:尽管有7000个名称为Réseau"的字段
My problem is that every fields with accents is not recognized . For example : despite having 7000 fields with the name "Réseau"
$query="Select * from dbo.Table where col1= 'Réseau'"
给出0个结果No rows found
与:
$query="Select * from [dbo].[Tablé]
给出一个SQL错误:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Object name 'dbo.Tablé' not valid., SQL state S0002 in SQLExecDirect in...
可悲的是,我在网上发现的所有提示都无济于事,例如:
And , sadly , none of the tips i found over the net helped , like :
'Réseau',Réseau
,[Réseau],收集SQL_Latin1_General_Cp437_CI_AI/French_CI_AS ...
'Réseau' , Réseau
, [Réseau] , COLLATE SQL_Latin1_General_Cp437_CI_AI/French_CI_AS ...
有关更多信息,我使用的是字符集UTF-8,我的数据库归类为French_CI_AS. 上面的所有查询都可以在Access或查询工具(使用ODBC)上完美运行.
For more info , I'm using charset UTF-8 , my database collate is French_CI_AS . And all the querys above works perfectly on Access or Query Tools (Using ODBC) .
- * 已编辑以阐明更多*
推荐答案
尝试在您的页面中设置语言环境,我发现设置我的所有特殊字符都有帮助:
Try setting your locale in your page, I found setting mine helped with all the special characters :
setlocale (LC_ALL, 'nl_BE');
这篇关于在SQL查询和表格名称中使用带有重音符号的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!