SQL
MySQL, MSSQL, T-SQL, MariaDB, Percona & more.
45 articles

SQL - The ntext data type cannot be selected as DISTINCT because it is not comparable - How to Fix
If you’ve stumbled upon this post you’re probably dealing with a SQL / T-SQL query which is either doing: a DISTINCT on a column having ntext data type. a JOIN with multiple queries and multiple tables; a UNION with two or more tables; And you’re
2 min read
LIKE operator equivalent for integer / numeric value Columns in a SQL (or T-SQL) Database
Those who’ve stumbled upon this post are probably looking for a way to perform a LIKE statement on a numeric value column in a MySQL, MariaDB or SQL Server Database. This usually happens when we need to restrict our results to those who match the
2 min read
MySQL - How to find all Table Columns in all Databases with a given Collation Name - Character Set Name
If you’ve stumbled upon this post it probably means that you’re trying to normalize the Collation of your Database(s), Table(s) and/or Column(s) to avoid hitting illegal mix type errors such as the following: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation … In case
2 min read
MySQL - How to convert all Database Tables and Columns to a specific Collation
A few months ago I wrote an article explaining how to convert all MySQL tables belonging to one or more Database(s) from MyISAM to InnoDB and vice-versa with a simple, yet effective CONCAT-based query. That same approach can be used if we need to convert
3 min read
How to copy, backup and restore one or multiple SQL Agent Jobs in SQL Server 2008-2017
Copying, moving, backing up and/or restore SQL Agent jobs is a common task for a SQL Server administrator: in this post we’ll see how it can be done for a single job or for multiple jobs at the same time. The technique can also be
2 min read
WordPress - How to perform Search and Replace on whole Database (post, pages, wp_options) using WP plugins or MySQL tools
Those who are frequently working with Worpress often find themselves operating mass-replace tasks throughout the whole WP Database. Such situation most likely arises in the following scenarios: WebSite URL change (from www.url-a.com to www.url-b.com), meaning we have to replace the old one in all of
3 min read
WordPress - How to retrieve all posts from one or more given categories with a SQL query
Today a client asked me to remove all the posts from a given category to the auto-generated XML Sitemap of his Wordpress blog and also redirect these posts to a new website (same slug, different host): here’s a quick report of how I managed to
3 min read
How to fix "MySQL server has gone away", "Packets out of order" and similar MySQL connection errors
If you’re a fond MySQL and/or MariaDB user you most certainly experienced at least one of these common errors: MySQL server has gone away Error reading result set’s header Error executing query MySQL server has gone away for query 2006, MySQL server has gone away
4 min read
How to fix MSXML2.XMLHTTP and MSXML2.ServerXMLHttp Error 0x80070057 - The Parameter is Incorrect
If you found this post it probably means that you are experiencing the following scenario: A Windows 2012 or Windows 2016 Server machine with SQL Server 2008, SQL Server 2008R2, SQL Server 2012, SQL Server 2014, SQL Server 2016 and so on. A Stored Procedure
5 min read
How to get the size of all MySQL Tables in all Databases (and other size-related queries)
Yesterday I was trying to investigate through an odd size increment affecting one of our MySQL databases. Since I didn’t knew about the table(s) affected by the issue, the first thing I needed to do was to take a look at each table size among
2 min read
MySQL Lock Wait Timeout Exceeded Error in InnoDB Tables - How to fix it
Today I was installing the latest (at the time of writing) MediaWiki build, which is 1.27.1, to a customer, together with all the bundled plugins and add-ins, following more or less the same steps i described here (installing within IIS), here (install WikiEditor) and also
4 min read
MySQL User Password Expired: how to (permanently) fix it
If you stumbled upon this post it probably means that your favourite MySQL management client (SQLyog, MySQL Workbench or any other) and/or your MySQL-based website or service is suddently unable to connect to your database server, leaving you with the following error message: Your password
4 min read