The IF ELSE statements are one of the most frequently used statement within SQL and control of flow statements are one of the core statements within any programing language. Once you have understood the concept you can easily make powerful scripts. An IF statement is a check to see whether a condition is TRUE and… Continue reading IF ELSE Control of flow statements
Have you ever wanted to change a databases state from read only to read write or vice versa? Well I am going to show you how using some easy to remember T-SQL which you will be using repeatedly over time. We received a database from a client the other day and noticed one of… Continue reading Change a database state in SQL
Have you ever wanted to list out all the databases you have on a server? Well I am going to show you how to do it quickly and easily. The other day I had completed a migration from a creaky old dinosaur server to a brand new powerful server which always brings a smile on… Continue reading List SQL databases in SQL Server
Have you ever wanted to return the time found in GETDATE or CURRENT_TIMESTAMP to a higher level off accuracy in SQL? Well I am going to show you how. The other day I needed to get the current time to greater accuracy due to the time stamp given to some records and I had to… Continue reading Find todays date & time in SQL Server part 2
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… Continue reading Have you ever wanted to convert a US date to UK format using SQL?
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… Continue reading Find the current day, month and year 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
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.… Continue reading Find a column in a database with INFORMATION_SCHEMA.COLUMNS
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… Continue reading SQL JOINS – INNER,OUTER( FULL,LEFT,Right) ,CROSS, SELF
Have you ever wondered how many DMVs are in SQL? Wondered whether a DMV exists which help diagnose your problems? Well I am going to show you how to list all the DMVs and DMFs so that you can do a deeper dive into them or await my series where I will be exploring each… Continue reading How to list all SQL DMVs (Dynamic management views) s and DMFs (Dynamic management functions ) in SQL Server?