What is a literal SELECT Statement?
A literal SELECT statement does not query a table. Instead, it returns the result of a string or expression. The classic programming example of this concept would be to try and return the string “Hello World” to the results section:
SELECT ‘Hello World’
By executing this query, you will notice that “Hello World” returns to your results. It is important to note that T-SQL uses single quotes to indicate a string of text. Be careful of this as other SQL variants and other programming languages use the double quote method to indicate strings.
We can return numbers and the results of mathematical expressions using literal SELECT statements as well. If we wanted to return the number 5 to our results section, we can execute the query:
If we wanted to return the result of 5 multiplied by 3:
Or, to return the result of adding 2 to 7:
SELECT 7 + 2
While literal SELECT statements are not the most complicated type of SQL query by any standard, they can be used in conjunction with more complicated queries later on. Learning these simple queries are a great starting point for SQL beginners and act as a way for you to become comfortable with the SQL Server Management Studio (SSMS) interface.