Tag Archives: sql

Passing Database and Table names as Variables in SQL Server

I often want to apply the same SQL to one or more tables in one or more databases.  This requires passing the  database and table as a variable (or copying and pasting the code multiple times). Below are three ways … Continue reading

Posted in Programming | Tagged , , , | 2 Comments

Column Dependencies in SQL Server

Having the need to do a column rename in the DB I wanted to try and find all references to the column to ensure I didn’t miss any. By using the INFORMATION_SCHEMA views in SQL server I used the following … Continue reading

Posted in Programming | Tagged , , , | Leave a comment

Counting Trailing Spaces in SQL Server T-SQL

I recently had an issue with some data grouping in a third party application where data that appeared to be the same, was being grouped separately. E.G. Example Data: AB AB AB BC BC BC BC BC BC DC When … Continue reading

Posted in Programming | Tagged , , , | 3 Comments

SQL Filters with Optional Parameters

Lets say, for example, you have some information on Cars that you want to filter buy either make, model, colour, or any combination of these.  I.e. if you select red cars you will get all makes and models that are … Continue reading

Posted in Programming | Tagged , , , , , | Leave a comment