Fix Error Msg 237 “There is insufficient result space to convert a money value to int” in SQL Server

If you’re getting error msg 237 that reads There is insufficient result space to convert a money value to int, it’s because you’re trying to convert a money value to an integer but the number’s too big to fit into an integer.

To fix this issue, make sure you convert the value to a data type that can handle the size of the number that you’re trying to convert.

Continue reading

Fix “Cannot DROP SEQUENCE ‘…’ because it is being referenced by object” in SQL Server

If you’re getting an error that reads something like “Cannot DROP SEQUENCE ‘Sequence2’ because it is being referenced by object ‘DF__Dogs__DogId__6C190EBB’“, it could be because you’re trying to drop a sequence object that’s referenced by a DEFAULT constraint.

Sequences that are referenced by a DEFAULT constraint can’t be dropped until the DEFAULT constraint is dropped.

Therefore, to fix this issue, drop the DEFAULT constraint first.

Continue reading

2 Ways to Set a Maximum and/or Minimum Value when Creating a Sequence in SQL Server

By default, SQL Server sets its own minimum and maximum values for sequence objects based on the data type of the sequence object. Assuming we don’t set the data type for the sequence, these min/max values are based on the bigint data type (because that’s the default data type for sequence objects in SQL Server).

However, we can also set our own minimum and maximum values for our sequences. We can do this either explicitly (by setting the MAXVALUE and MINVALUE properties) or implicitly (by setting the data type).

Continue reading

Fix “START value (…) cannot be less than MINVALUE (…)” When Creating a Sequence in PostgreSQL

If you’re getting an error that reads something like “START value (0) cannot be less than MINVALUE (1)” in PostgreSQL when you’re trying to create a sequence, it’s because your sequence’s start value is lower than its minimum value, when it should be at least the same or higher.

To fix this issue, be sure that the sequence’s start value is at least the same or greater than the minimum value.

Continue reading