Fix “Cannot drop a default constraint by DROP DEFAULT statement. Use ALTER TABLE to drop a constraint default.” in SQL Server

If you’re getting an error that reads something like “Cannot drop a default constraint by DROP DEFAULT statement. Use ALTER TABLE to drop a constraint default“, it’s because you’re trying to use DROP DEFAULT to drop a DEFAULT constraint.

The DROP DEFAULT statement has been flagged for deletion from SQL Server, and Microsoft recommends that we use the ALTER TABLE statement to drop DEFAULT constraints.

Therefore, to fix this issue, use the ALTER TABLE statement to drop the DEFAULT constraint.

Continue reading

Fix “ERR wrong number of arguments for ‘hstrlen’ command” in Redis

If you’re getting an error that reads “ERR wrong number of arguments for ‘hstrlen’ command“, it’s because you’re passing the wrong number of arguments when using the HSTRLEN command.

The HSTRLEN command requires two arguments (at the time of writing). These are the name of the key and the name of the field.

If you’re getting this error, check the number of arguments that you’re passing and adjust if required.

Continue reading

Fix “ERROR 1054 (42S22): Unknown column ‘…’ in ‘on clause'” in MySQL

If you’re getting an error in MySQL that reads something like “ERROR 1054 (42S22): Unknown column ‘c.DogName’ in ‘on clause”“, here are three likely causes:

  • The column doesn’t exist.
  • You’re trying to reference an aliased column by its column name.
  • Or it could be the other way around. You could be referencing the column with an alias that was never declared.
Continue reading

How CONVERT() Works in MySQL

In MySQL, CONVERT() is a built in function that converts a value to another data type. It takes a value of one type and returns a value of the specified type.

We provide the value as an argument when we call the function, as well as the type that we want it converted to.

The CONVERT() function is similar to the CAST() function, which also converts between data types.

Continue reading

How to Specify the Data Type when Creating a Sequence in SQL Server

When creating a sequence object in SQL Server, the default data type is bigint. However, we can change this so that the sequence uses a data type of our choosing, as long as it’s an integer type (see below for accepted data types).

We can set the data type of a sequence by using the AS argument when defining the sequence.

Continue reading