Invalid column name, column accents in MS SQL Serv

2019-08-20 03:18发布

问题:

I'm currently working with an old database that has column names containing accents. When I try to execute this query in Codeigniter (PHP):

SELECT *
FROM [empresas] [em]
LEFT JOIN [clientes] [cl] ON [em].[empresa] = [cl].[Código]

The system throws the error

"Invalid column name 'Código'". (the column name is 'Código')

I've tried using COLLATE function with no success.

The MS SQL Server database default collation is Modern_Spanish_CI_AI and the column collation is SQL_Latin1_General_CP1_CI_AS.

How can I solve this problem?

Codeigniter has a configuration field name "dbcollation" that sets the collation used to communicate with the database but I don't know if it affects in this problem (I've tested some values with no success too).

Thank you.

回答1:

You should convert your database collection into utf8_general_ci