Learn more about SQL Server tools

   
   























Latest from MSSQLTips














Free SQL Server Learning

Get your SQL Server in shape this Summer with Spotlight on SQL Server

Encrypting Data with SQL Server

Physical and Virtual Performance Monitoring with SQL Diagnostic Manager















SELECT command for SQL Server




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 the core command to access data in SQL Server.  The main components of a SELECT statement are:

  • Column listing - either specific columns or * (SELECT list)
    • When * is specified, then all columns from the tables included in the FROM clause are included
  • Table listing (FROM clause)
  • Filter logic (WHERE clause)
  • Summarize values (GROUP BY)
  • Filters the GROUP BY values (HAVING)
  • Sorting logic (ORDER BY)

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

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

You can either use the outline on the left or click on the arrows to the right or below to scroll through each of these topics.







 
Sponsor Information