I wrote a plugin for a client that worked perfectly on my localhost LAMP installation, but failed when running on their production site that uses MSSQL as the database.


The error occurred when setting the status of a column in the database to ‘1’. Viewing the insert does not reveal to much, so at first glance the problem and solution are not immediately obvious.


In looking for a solution I come across this tracker post, which helped my identify the problem, and ultimately the solution

The problem was that I was using TINYINT as a DataType in my flag DB column. Perfectly fine for MySQL, but not for MSSQL.

I discovered this by looking more carefully at the error from the cron log, and then checking the available DataTypes in lib/dml/mssql_native_moodle_database.php.


The fix was simply to change the DataType to INT. I could have, as the solution in the tracker suggested added TINYINT to the php file. But, that’s a change to core, and the better solution is to fix your own code, not Moodle.

Leave a Reply

Your email address will not be published. Required fields are marked *