SQL SELECT Nth Record

Transact-SQL (TSQL) Quick Tips – SQL SELECT Nth Record I recently needed to compare two month end data snapshots.  The data was organized in a historical table with monthly datasets, dating back several years.  The specific need was to query changes between the previous dataset and the most recent.  The task itself isn’t difficult.  What … Read more

SQL PIVOT

Transact-SQL (TSQL) Quick Tips – SQL PIVOT Here is a simple example of how SQL PIVOT works in TSQL.  You can copy this code into your Query Window and EXECUTE as-is.  The code includes a #temp table with data to illustrate the functionality.  You can modify to suit your needs. The PIVOT functionality is used to … Read more

SQL CHARINDEX

Transact-SQL (TSQL) Quick Tips – SQL CHARINDEX Function Here is a simple example of how the SQL CHARINDEX function works.  You can copy this code into your Query Window and EXECUTE as-is.  The code includes a #temp table with data to illustrate the functionality.  You can modify to suit your needs. The SQL CHARINDEX function searches … Read more

SQL SUBSTRING

Transact-SQL (TSQL) Quick Tips – SQL SUBSTRING Function Here is a simple example of how the SQL SUBSTRING function works.  You can copy this code into your Query Window and EXECUTE as-is.  The code includes a #temp table with data to illustrate the functionality.  You can modify to suit your needs. The SQL SUBSTRING function returns … Read more

SQL REPLACE

Transact-SQL (TSQL) Quick Tips – SQL REPLACE Function The following post contains a simple example of the SQL REPLACE function.  I encourage you to copy the code provided below, then paste the code into your Query Window and EXECUTE as-is.  If you execute the code yourself, you will better understand how the SQL REPLACE function works.  The code includes a temp table with data to … Read more