sql

SQL to get max length of values in every table column I had an issue to resolve once upon a time where data could not be loaded into a table because “string or binary data would be truncated”. The target… Continue Reading →

SQL “Watchdog” loop to start and monitor SQL Agent Jobs This runs an SQL “Watchdog” loop to start and monitor SQL Agent Jobs. There are just a few configurable items that you can adjust to suit your needs: The “Wait… Continue Reading →

LIKE vs SUBSTRING vs LEFT/RIGHT vs CHARINDEX All too often developers need to query a database table for records which begin and/or end with a certain textual pattern. For instance, find all employees where their first name begins with “DAV”.… Continue Reading →

Fastest way to insert new records where one doesn’t already exist SQL Developers come across this scenario quite often – having to insert records into a table where a record doesn’t already exist. The age-old technique and I suspect most… Continue Reading →

Fastest way to compare multiple column values I was recently working on a project with stored procedures that had a significant amount of column comparisons in a MERGE statement. This was turning into a real performance bottleneck (relatively speaking) as… Continue Reading →

Optimizing SQL Strategies How many of you have come across SQL code that, for whatever reason, wasn’t written as good as it could have been? I’m not talking about going into the inner workings of your database’s engine and milking… Continue Reading →