Go to Top

MSSQL

Stop a MSSQL query

Following on from my earlier post today about I figured I should include this post purely on how to stop a MSSQL query if there are results as this is mentioned in my other blog post. I’m always looking for ways to streamline processes and I see no use in continuing to run queries if they are not actually going to affect any records therefore I believe it’s important to …Read More

Using IF and ELSE in MSSQL

This guide explains how to use IF and ELSE in MSSQL. IF and ELSE statements can be very usefull in MSSQL in alot of situations especially when you need to verify something prior to deleting or changing the record. It works in a very similar way to php. In PHP it is: In SQL you use it with the same structure in mind. For example: The above query selects a …Read More

Cleaning phone numbers in MSSQL

Below are some code snippits that should help you with cleaning phone numbers in MSSQL. I recently used it to remove spaces and +44 from mobile phone numbers replacing it with a 0. Before i start with the code i will explain a few symbols that i’m using here which people may or may not have seen before. First of all %. % is used in MSSQL to define any …Read More

Querying Multiple Tables in Multiple Databases MSSQL

Recently i had the task of querying multiple tables in multiple databases in Microsoft SQL Server. I thought i’d share it online for anyone else who may be looking at or struggling doing the same thing. Once you see the code it makes sense and is fairly straight forward but i will comment the code so you can see what does what etc. Lets say you have a database containing …Read More