The SELECT Statement is used to query the data stored in a given table of a database. The data which is returned by executing the SELECT statement is referred as result-set.
Within a database data is stored within tables. In a table the data is stored in rows and columns.
In this tutorial, you will learn about Transact-SQL (T-SQL) along with relevant examples. To understand each topic in detail we recommend you to follow the sequence of articles.
This is Part 1 of 40 Part SQL Server T-SQL Tutorial.
Topics Covered in SQL Server T-SQL Tutorial are:
- SQL Server SELECT Statement
- SQL Server SELECT TOP Clause
- SQL Server SELECT DISTINCT Clause
- SQL Server ORDER BY Clause
- SQL Server WHERE Clause
SELECT Syntax / SQL Server SELECT Statement Syntax
Use <DatabaseName> GO SELECT column1, column2, column3,....... FROM schema.table GO
SQL Server SELECT Statement: How to Query Data from a Table in SQL Server
How to SELECT all columns from a table
To select all the columns and data from a table execute the below SELECT Statement in SQL Server Management Studio (SSMS).
Use the below script to fetch the data from AdventureWorks2016 sample database in SQL Server 2016. For more information on How to Download SQL Server 2016 and Sample Database, refer How to Download SQL Server 2016 Developer Edition for Free.
Use AdventureWorks2016 GO SELECT * FROM HumanResources.Employee GO
How to SELECT required columns from a table
To select some of the columns and data from a table execute the below SELECT Statement in SSMS.
Use AdventureWorks2016 GO SELECT FirstName , LastName FROM Person.Person GO
We recommend you to go thought all the topics of SQL Server Transact-SQL Tutorial in the sequence for better understanding of Transact-SQL. Click Next Page button to continue reading the topics and click on the Previous Page button to revisit the previous topic.