In SQL Server, we can query the sys.check_constraints
system catalog view to return a list of CHECK
constraints in the current database.
Tag: how to
Fix “ERR wrong number of arguments for ‘srem’ command” in Redis
If you’re getting an error that reads “ERR wrong number of arguments for ‘srem’ command” in Redis, it’s probably because you’re calling the SREM
command with the wrong number of arguments.
To fix this issue, make sure you pass the correct number of arguments. At the time of writing, the SREM
command requires at least two arguments.
Return the Definition of All Computed Columns in a SQL Server Database (T-SQL)
In SQL Server we can run a query against the sys.computed_columns
system catalog view to return all computed columns and their definitions.
How to Insert Multiple Rows in SQL
When working with SQL, we can use the INSERT
statement to insert a new row into a table. But what if we want to insert more than one row?
Fortunately, we can still use the INSERT
statement. Below is a quick example that inserts multiple rows using SQL.
How to Drop a DEFAULT Constraint in SQL Server
In SQL Server, we can drop DEFAULT
constraints by using the ALTER TABLE
statement with the DROP CONSTRAINT
argument.
How to Add Multiple Fields to a Redis Hash
Ever since Redis 4.0.0, the HSET
command has allowed us to add (and update) multiple fields to a hash.
Prior to Redis 4.0.0, we needed to use the (now deprecated) HMSET
command to add more than one field at once.
Fix “The requested range for sequence object ‘…’ exceeds the maximum or minimum limit. Retry with a smaller range.” (Error 11732) in SQL Server
If you’re getting an error that reads something like “The requested range for sequence object ‘Sequence1’ exceeds the maximum or minimum limit. Retry with a smaller range.” in SQL Server, it’s probably because you’re trying to return a value that’s outside the range of the sequence object.
This can happen when you’re using the sp_sequence_get_range
stored procedure to return a range from a sequence object that exceeds the minimum or maximum value for that sequence object, and the sequence object does not have CYCLE
defined. It’s a similar error to error 11728, which can happen when using NEXT VALUE FOR
to generate a new value from a sequence.
Fix Error Msg 11728 “The sequence object ‘…’ has reached its minimum or maximum value.” in SQL Server
If you’re getting an error that reads something like “The sequence object ‘…’ has reached its minimum or maximum value. Restart the sequence object to allow new values to be generated.“, it’s probably because you’re using a sequence that’s reached the minimum or maximum value specified in its definition.
Continue readingGenerate a CREATE TABLE Script for an Existing Table in MariaDB
We can use MariaDB’s SHOW CREATE TABLE
statement to generate a CREATE TABLE
script for existing tables in the database. This allows us to recreate the table without having to manually type out the table’s definition.
The statement requires SELECT
privilege for the table.
Fix “NEXT VALUE FOR function cannot be used directly in a statement that contains an ORDER BY clause unless the OVER clause is specified.” in SQL Server (Error Msg 11723)
If you’re getting an error that reads “NEXT VALUE FOR function cannot be used directly in a statement that contains an ORDER BY clause unless the OVER clause is specified” in SQL Server, it’s probably because you’re trying to sort the results of a query that uses the NEXT VALUE FOR
function without using the OVER
clause.