Returning all data from a table
1. Get all data from a table
Select some columns
Filtering rows
Logic
Text patterns
To be or NULL to be
A bit of mathematics
Let's practice

Instruction

It's time to run your first T-SQL query! As you remember, the data in a database is stored in tables.

You can retrieve all data from the User table with this query:

SELECT
  *
FROM User;

SELECT tells your database that you want to select data. FROM User tells the database to select data from the User table.

Finally, the asterisk (*) tells the database that you want to get all columns from this table.

In SQL Server, you should always end your statement with a semicolon (;) or GO. A semicolon or GO at the end of a query is like a period at the end of a sentence – it tells SQL Server that you're done with your command. However, there is a slight difference between a semicolon and GO, but that is beyond the scope of this course.

Our platform accepts both a semicolon and GO at a end of the statement. However, it also accepts your query submissions without them, so you can leave them out completely.

Exercise

In our example database there is a table named Car that contains information about various of cars.

Select all data from the Car table and click Run and check code.

Stuck? Here's a hint!

Type:

SELECT
  *
FROM Car;