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

2
  • 5
    If you want to live a happy life, always use only use standard ascii chars for table and field definitions. Commented Mar 22, 2013 at 8: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. Commented Apr 17, 2013 at 11:39

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.