6

I've been searching this topic, but haven´t found any solution; there was a similar question, but it is not solved: Working with characters with accents in sql query and table name

I'm working with a database on a SQL Server 2005 that uses Modern_Spanish_CI_AS as collation. I'm developing a web front-end using PHP, and I am stuck with an accent problem.

There's a table (let's say "Objetos") whose fields are: ID Name Descripción

I can´t query this table because of the accent. If I build my query "Select a.ID, a.Name FROM Objetos" it works perfect, but if changed into "Select a.ID, a.Descripción FROM Objetos" it returns zero rows.

I can´t change the collation of the database, so I have been decoding the queries before sending them $ssql = utf8_decode($ssql);... It is strange, using this workaround I can do INSERT, but cant SELECT.

Any ideas? Thanks

Community
  • 1
  • 1
Pete
  • 171
  • 2
  • 2
  • 12
  • 5
    If you want to live a happy life, always use only use standard ascii chars for table and field definitions. – Teson Mar 22 '13 at 08:09
  • As user247245 said, you will have a hell of a rough ride if you use anything but lower ansi characters for table/column names. You should follow the same rule as in any other language: Entitie names MUST not contain special characters. In addition to that. You should ALLWAYS use utf8_general_ci or one of it's sisters for all your databases and tables. This collation contains any and all special chars and can easily used in any programming code. – ToBe Apr 17 '13 at 11:39

1 Answers1

1

Try surrounding the column with the "`" character. If it doesn't work, try removing the "a." prefix from the column name.

Clay Freeman
  • 533
  • 5
  • 17