Working with accented characters in sql query and table name

I am doing php and SQL Server 2005 in a database with accents (é, è, à) in table names, column names and fields. Unfortunately, I am not the owner / creator of this database, but I agree that the owner should be deleted :).

I am using an ODBC driver to connect to SQL Server odbc_connect($dsn,$user,$password) .

My problem is that all fields with accents are not recognized. For example: despite having 7000 fields named "Réseau"

 $query="Select * from dbo.Table where col1= 'Réseau'" 

gives 0 results No rows found

The same goes for:

 $query="Select * from [dbo].[Tablé] 

gives sql error:

 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, unfortunately, none of the tips I found through the network helped, for example:

'Réseau', Réseau , [Réseau], COLLATE SQL_Latin1_General_Cp437_CI_AI / French_CI_AS ...

For more information, I use UTF-8 encoding, my database is French_CI_AS. And all the queries above work fine on Access or Query Tools (using ODBC).

  • * EDITED specify more *
+1
source share
2 answers

try

 $q="Select * from DatabaseTable where col1= N'Réseau'" 
0
source

Try setting your language on your page, I found that setting mine helped with all the special characters:

 setlocale (LC_ALL, 'nl_BE'); 
0
source

All Articles