How to do a DELETE Pass-Through Query in SQL Server

In SQL Server, the OPENQUERY rowset function enables you to execute a pass-through query on a linked server.

OPENQUERY is commonly referenced in the FROM clause of a query as if it were a table, but it can also be referenced as the target table of an INSERT, UPDATE, or DELETE statement.

This article presents an example of using OPENQUERY to do an DELETE pass-through query.

Read more

MariaDB JSON_LENGTH() Explained

In MariaDB, JSON_LENGTH() is a built-in function that returns the length of a JSON document.

When you call this function, you provide the JSON document as an argument. You can also provide a path argument to return the length of a value within the document.

Read more

MariaDB JSON_KEYS() Explained

In MariaDB, JSON_KEYS() is a built-in function that returns an array of the top-level keys from a JSON document. If a path is provided, it returns the top-level keys from that path.

It excludes keys from nested sub-objects in the specified level.

Also, if the selected object is empty, an empty array is returned.

Read more

Restore a SQL Server Database (T-SQL)

If you use SQL Server Management Studio (SSMS) or some other GUI to manage your databases, you might be used to backing up and restoring databases using “point and click”.

Usually this involves right-clicking on the database and selecting Restore or similar, then following the prompts (for example, when restoring a database in Azure Data Studio).

But if you ever need to do it with T-SQL, you can use the RESTORE DATABASE statement.

Read more

MariaDB JSON_EXISTS() Explained

In MariaDB, JSON_EXISTS() is a built-in function that allows you to check whether a value exists at a specified path in the JSON document.

It accepts the JSON document as an argument, and returns 1 if the path is found, and 0 if it’s not.

The MariaDB documentation states that the function “determines whether a specified JSON value exists in the given data”. However, the function doesn’t actually appear to check for a given value. It’s probably more accurate to say that it determines whether a specified path exists, or that a value exists at the specified path.

For checking that the actual value exists, you can use the JSON_CONTAINS() function.

Read more