What is ACID ( Atomicity, Consistency, Isolation, Durability)?

Atomicity – this basically means the transaction works or doesn’t and is sometimes called the “all or nothing” rule. I always liken it to an Atomic bomb because they either work or fail. A failed transaction would then enter a state of rollback. Consistency – this means only valid data is  written to the database. […]

What is SQL?

SQL stands for Structured Query Language. It is an ANSI standard language which means it is an industry recognised standard language which can be used across a plethora of database management systems. I must caveat the fact that although it is an ANSI standard language minor variations do happen in T-SQL ( SQL Server ), […]

Create a new column with an Expression

Sometimes there may be a requirement to create a new column based upon existing columns with a minor manipulation. For example in the AdventureWorks database the table TransactionHistoryArchive shows the quantity and the actual cost of each unit but not the total value of the order. That would be achieved by multiplying the Quantity and […]

AS – Rename output columns

Sometimes when you run a query you may want to rename the columns in the results. This is quite a simple process within SQL. First you will need to know the source column names. For example USE AdventureWorks GO SELECT * FROM [HumanResources].[Department] Or you can open up the table which gives the column names. […]

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: