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
The Microsoft Drivers for PHP for SQL Server enable integration with SQL Server for PHP applications. The drivers are PHP extensions that allow the reading and writing of SQL Server data from within PHP scripts.
Return Values ¶ Returns a statement resource on success and false if an error occurred.
Arrays can be used only in the following contexts: Parameters to SQL functions. RETURN data types from SQL functions. Parameters to SQL procedures.
Conclusion. As you can see, SQL Server does not include arrays. But we can use table variables, temporary tables or the STRING_SPLIT function. However, the STRING_SPLIT function is new and can be used only on SQL Server 2016 or later versions.
Try surrounding the column with the "`" character. If it doesn't work, try removing the "a." prefix from the column name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With