SQL Server Home @ it-notebook.org

How to...retrieve all data from a table

(Kristofer Gafvert, October 9, 2009)

If you want to see all columns in a table, you can do the following:

SELECT *
FROM person.address

The asterisk symbol (*) has a special meaning - it returns all columns from the specified table. Do note however that it is better to explicitly reference the columns you want, especially when writing program code. If you later add a column, or change the order of the columns, your application may break because it expected the data to be retrieved in a certain order. By explicitly specifying the column names, you eliminate this to happen.

It may also negatively influence the performance by using * in your query. Say that your query returns millions of rows over a slow network connection, and all you need is the data from one column. It may slow down the query by returning unwanted data.

Applies to [?]

SQL Server 2008

See also