SELECT — Returning specific columns — Parv The IT Geek

There are many times where returning all the data held within all the columns in a table are unnecessary and inefficient.

For example.

SELECT * FROM HumanResources.Department

If you expand out the HumanResources.Department then you will get a list of the columns as well as some information on the columns.

To get only the DepartmentID and Name columns the following query would be needed.

SELECT DepartmentID,Name FROM HumanResources.Department

Originally published at https://parvtheitgeek.com on January 4, 2014.

Published by Parvinder Nijjar

I blog at ParvTheITGeek.com

Leave a comment