If you’re getting SQL Server error 2788 that reads “Synonyms are invalid in a schemabound object or a constraint expression” it seems that you’re trying (whether intentionally or not) to create a schemabound object that includes a synonym in its definition, or a constraint with a synonym in its expression.
Continue readingTag: errors
Fix Error “Truncate failed on table … because it is not a supported operation on system-versioned tables.” in SQL Server
If you’re getting an error that reads something like “Truncate failed on table ‘test.dbo.ProductInventory’ because it is not a supported operation on system-versioned tables.” in SQL Server, it’s probably because you’re trying to truncate a system-versioned temporal table.
In SQL Server, if a table is defined as a temporal table, we can’t truncate it while it’s using system-versioning.
Continue readingWhen LPAD() or RPAD() Don’t Seem to Work in PostgreSQL
If you’re trying to use either lpad()
or rpad()
to pad a string in PostgreSQL but it’s just not working, maybe it’s because of the reasons listed below.
Fortunately this issue has a simple fix, and it can be resolved within seconds.
Continue readingFix “date/time field value out of range” in PostgreSQL
If you’re getting an error that reads ‘date/time field value out of range‘ in PostgreSQL while using a function such as date_add()
, date_subtract()
, or date_trunc()
, it’s probably because the date value you’re passing to the function is an invalid date.
It’s possible that you’ve got the month and day in the wrong order.
To fix this issue, be sure that you pass a valid date. It may be that all you need to do is switch the day and the month around. Or it could be that you need to change your datestyle
setting.
Fix Error “cannot take logarithm of zero” in PostgreSQL
If you’re getting an error that reads “ERROR: cannot take logarithm of zero” when using either the log()
function or log10()
function in PostgreSQL, it’s probably because you’re passing an argument of zero.
These functions require a value greater than zero. This is true even for the base argument of the log()
function (the argument that specifies which base to use).
To fix this issue, be sure to pass a value greater than zero to these functions.
Continue readingFix Error “cannot take logarithm of a negative number” in PostgreSQL
If you’re getting an error that reads “ERROR: cannot take logarithm of a negative number” when using either the log()
function or log10()
function in PostgreSQL, it’s probably because you’re passing a negative value to the function.
These functions require a value greater than zero. This is true even for the base argument of the log()
function (the argument that specifies which base to use).
To fix this issue, be sure to pass a value greater than zero to these functions.
Continue readingFix ‘time zone … not recognized’ in PostgreSQL
If you’re getting an error that reads something like ‘time zone “US/New_York” not recognized‘ in PostgreSQL while using a function such as date_add()
, date_subtract()
or date_trunc()
, it’s probably because you’re specifying an unsupported time zone.
If you specify a time zone, it must be one that’s recognised by the system.
To fix this issue, either provide a recognised time zone or omit the time zone argument altogether (assuming this is a valid option for the situation).
Continue readingFix “function array_shuffle(numeric) does not exist” in PostgreSQL
If you’re getting an error that reads “function array_shuffle(numeric) does not exist” when using the array_shuffle()
function in PostgreSQL, it’s probably because the argument you’re passing to the function is not an array.
More specifically, this error message implies that you’re passing a numeric type. The same error can occur when passing other non-array types (such as integer), but the solution is the same.
The argument for this function must be an array.
To fix this error, replace the numeric value with an array value when calling the array_shuffle()
function.
Fix Error “cannot determine type of empty array” in PostgreSQL
If you’re getting an error that reads “cannot determine type of empty array” in PostgreSQL, it could be that you’re trying to create an empty array without specifying the array type.
It’s impossible to create an array with no type, and so if we want to create an empty array, then we need to specify the type or add items to determine the type.
To fix this issue, either specify the array type for the empty array, or add items to the array.
Continue readingFix Error “time field value out of range” when using make_time() in PostgreSQL
If you’re getting an error that reads ‘time field value out of range‘ in PostgreSQL while using the make_time()
function, it’s probably because one or more of the time parts you’re providing is out of the accepted range for that time part.
To fix this issue, be sure that each time part you provide is within the valid range for that time part.
Continue reading