SELECT command for SQL Server Tutorial



By:
Overview

If you are starting to learn the T-SQL language then starting with the SELECT statement makes a great deal of sense. The SELECT statement is used to access data and is generally the most used command in SQL Server. The main components of a SELECT statement are:

SELECT -- Column names
FROM -- Table or View name
WHERE -- Filter criteria
GROUP BY -- Logic to roll-up records
HAVING -- Criteria for GROUP BY logic
ORDER BY  Sort data either ASC (ascending) or DESC (descending) by column name or position

SELECT can be combine with other statements to do the following:

  • JOIN - JOINing data from multiple tables to build a single result set
  • Add Records - INSERT with a SELECT statement to add records into an existing table
  • Add Records - SELECT...INTO statement to create a new table based on the column list specification and enter records into the new table
  • Combine Results - UNION or UNION ALL command to have multiple set of logic returned in a single result set
  • Improve Performance - Include an index hint to force a particular lock level or index usage for the query

You can either use the outline on the top left of this tutorial or click on the arrows below to scroll through each of these topics in this tutorial

Additional Information

Last Update: 6/18/2020






Comments For This Article





download


get free sql tips
agree to terms


Learn more about SQL Server tools