Have you ever wanted to convert a US date to UK format using SQL?

Have you ever come across the situation where you have data in US format and need it changed to UK format? Well I am going to show you how to use SQL to easily reformat the date. I have had this problem several times in the past dealing with international clients who supply databases with […]

Find the current day, month and year in SQL Server

Have you ever wanted to return the value of the current day? Month? Or year? Well its easy in SQL and I am going to show you how. The query for the current day is below. SELECT DAY(GETDATE()) The query for the current month is below. SELECT MONTH(GETDATE()) The query for the current year is […]

Find todays date and time in SQL Server

Have you ever wondered how to get the current time and date within SQL Server? Well I am going to show you two easy methods of getting this information. The first method is my preferred method as it’s slightly shorter than the second method. SELECT GETDATE() SELECT CURRENT_TIMESTAMP

Find a column in a database with INFORMATION_SCHEMA.COLUMNS

Have you ever just been given a column name and not known which table it was in? Needed to check whether a column existed within a database?… Well today I was just given a column name and told the information I needed was in there but alas they didn’t know which table it was in. […]

SQL JOINS – INNER,OUTER( FULL,LEFT,Right) ,CROSS, SELF

Have you ever been baffled when people talk about SQL joins? Mystified when you hear inner, outer, cross or self? Ran away in fear at the thought of joining two tables? Well I am about to help you out and face down those fears and explain to you what joins are, the different types and […]

Powershell and my first script for Hello World.

It has become a repeated custom that whenever a person is learning a new programming language that they begin with the Hello World program. This is quite simply a rite of passage and a welcome milestone so I started here and have put the script below. Hopefully in the next few weeks I will be […]

Use SQL to search a column for a range of values

Have you ever wanted to search for a column for a range of values? For example if you were searching for Product ID which ranges from 1 to 300, or look for a range of names starting A to D. Well I can show you how to do these quickly and easily by using the […]

Search for a list of values using the IN command in SQL

Have you ever been presented with a list of values which need to be found in a column or wondered how to search for a list of exact names, addresses, numbers without using wildcard searches or ranges. Well SQL has the answer and it is the IN command. The above query produces 16 rows of […]

NULL Values – How to filter out NULLS and how to find NULLS using SQL

Have you ever wanted to find a NULL value or filter out NULL values within a column? Well SQL has the solution and our saviour is the ‘IS NULL’ and ‘IS NOT NULL’ commands. Using them in a ‘WHERE’ clause will allow us to do the filtering out appropriately. The above query bring us a […]

AS – Use Aliases / Shorthand in SQL to make more readable queries

Have you ever wondered how I can make my SQL queries look more readable, manageable and simpler? Well the answer is to use the ‘AS’ command as this can alias tables. For example the below query can seem quite daunting with long table names. However, the below query using the ‘AS’ command to alias the […]

%d bloggers like this: