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
Output
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
Output
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.