Tag Archives: tsql

Search for Value in Multiple Columns SQL Server T-SQL

Having to write some SQL SELECT’s on some un-normalized tables left me thinking there has to be a tidier way. I started with: (@SCAN_ID is a variable declared earlier) I ended up with: Maybe not a massive improvement, but personally … Continue reading

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

Multiple OR’s in T-SQL WHERE Condition SQL Server

Just been rewriting some SQL Server stored procedures for a client. There were a lot of SELECT statements like the one below: I’ve seen this quite a few times, and I’m not suggesting this is wrong, however I find that … Continue reading

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

Parametrised SQL Server Stored Proc From ASP.net / C# / OLEDB

Lets assume that we have a stored procedure that is defined in the following way, it doesn’t really matter what the actual body of the SQL is: We want to be able to call this procedure from an ASP.net page … Continue reading

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

Find Updated Objects in SQL Server

Quickly find SQL Objects that you updated “today”: Clearly if you wanted to change the updated date you could enter a specific date or range.

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

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