VALUE

VALUE in SQL is a keyword used in the INSERT statement. It specifies the data values that you want to insert into a table's columns. Each value corresponds to a specific column in the table.

Example

DECLARE @MyVar AS INT;
SET @MyVar = 5;
SELECT VALUE = @MyVar;

Output

VALUE
5

Explanation

In the code provided, a variable @MyVar is declared as an integer (INT) data type in SQL Server. The SET statement is then used to assign the number 5 to @MyVar. Finally, the SELECT statement, used with the VALUE keyword, outputs the current value of @MyVar, which is 5. The VALUE keyword helps assign a column alias in the ‘SELECT’ statement output.

Example

SELECT VALUE(e)
FROM (SELECT TO_NUMBER('10') AS e FROM dual);

Output

10

Explanation

The VALUE function accepts a single parameter, and simply returns that parameter. In this example, we use it to select a number converted from a string, ‘10’. The output from Oracle is plain text 10.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.