Skip to content

FROM statement is completely optional in T SQL

Kristina edited this page Nov 15, 2017 · 1 revision

An interesting fact about T-SQL is that the FROM clause is optional. So you can write a statement like below in Microsoft SQL Server and it will work:

SELECT 5 * 4;

Note: This will return a single row with 20 as the value and a blank column name

Almost all of the SQL statements will have a FROM clause because SQL statements are normally used to select data from a table. I just found this information interesting.

In Oracle you have to have a FROM clause in the SQL statement but you can use the DUAL in-memory table to get the same results.

SELECT 5 * 4 FROM DUAL;

Note: This will return a single row with 20 as the value and a blank column name

Clone this wiki locally