# Category T-SQL

## Generate random data

The following is a quick & easy way to generate some random data in a temp table. It’s not very complex but it can be useful for quick testing purposes. Notes: NEWID creates a UniqueIdentifier datatype with a length of 36 characters (including hyphens). GO x (where x is an integer) will execute the batch […]

## Filter Data in Outer Joins

Aim: To clarify the difference between filtering data in a WHERE clause or within the OUTER JOIN. When using an OUTER JOIN, there will be a difference in the results depending on whether the data is filtered in a WHERE clause or within the OUTER JOIN itself. The below queries have been run against a copy […]

## Replace Multiple String Patterns

I recently came across an interesting way of using the REPLACE function in SQL Server to replace multiple (different) string patterns. Usually, we use the REPLACE function in the following way if we want to replace multiple string patterns. DECLARE @string AS VARCHAR(MAX) = ‘This is a banana. It may be found in the fruitbowl. Beside […]

## Matrix Multiplication Using SQL

This week I found out how to perform matrix multiplication using SQL. I don’t think I’ve touched matrix multiplication since university so first I gave myself a quick refresher in the mathematics. To multiply two matrices (A x B), e.g. First, determine the size of the resulting matrix which will have the same number of […]