Book Image

SQL Server 2014 Development Essentials

By : Basit A. Masood-Al-Farooq
Book Image

SQL Server 2014 Development Essentials

By: Basit A. Masood-Al-Farooq

Overview of this book

Table of Contents (14 chapters)
SQL Server 2014 Development Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding Transact-SQL SELECT, FROM, and WHERE clauses


In this section, you will learn how to use the Transact-SQL SELECT, FROM, and WHERE clauses to retrieve the data you need from the SQL Server databases.

The SELECT statement

The SELECT statement is the most frequently used Transact-SQL statement. We use the SELECT statement for the following purposes:

  • To query specific data from the selected database tables

  • To assign a value to local variables

  • To call a function

We often see SELECT statements within programming objects (such as views, stored procedures, functions, batches, and common table expressions (CTEs)). We also use SELECT statements to run ad hoc queries, most often through an SSMS 2014 query window. The SELECT statement has several clauses, most of which are optional. The following is the general syntax of the SELECT statement:

SELECT [TOP(n)|TOP(n) PERCENT] [ALL|DISTINCT] select_list
[INTO[[database.]owner.]table_name]
FROM[[[database.]owner.]table_name|view_name|UDF]
[WHERE...