SELECT – Returning specific columns

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 […]

SELECT – Return results from all columns

There is a simple way to return information from all the columns in SQL. SELECT * FROM INSERTTABLENAME For example SELECT * FROM HumanResources.Department As you can see the query returned 16 rows of information with all the columns.

USE – Select a database in SQL

Before you can start querying a database you will need to select the database first. This is done using the USE command USE Enteryourdatabasenamehere For example USE AdventureWorks This will change the queried database to AdventureWorks

SQL – Hello World

In a time-honoured tradition in every programming language the first thing they teach you is how to get the system to put ‘Hello World’ on to your screen. This is accomplished by using the below command. PRINT ‘HELLO WORLD’ Play about with the PRINT command and see what else you can get the system to […]

SELECT – The basis of the SQL language

The SELECT query is the basis of SQL and is the most commonly used syntax within SQL. SELECT basically means retrieve. For example the query SELECT 1 returns 1. SELECT ‘This is an example of the SELECT statement’ As you can see the SELECT query is simply retrieving the number or word and returning that […]

%d bloggers like this: