Adventures in Data Engineering — Basic UDFs

Ryan Howe
6 min readJul 16, 2023

Note : everything I’m talking about is in reference to MS SQL however I’m going to use MySQL in the examples. Why? I only have MySQL installed locally.

I was working on a job recently to drop some temp tables based on some conditions using a stored procedure and a daily SQL Agent Job. It looks like the following

  1. Loop over a number of system metadata tables (sys.tables, sys.schemas, sys.dm_db_partitions) for some databases I want to clean up with T-SQL to find the tables that match my criteria (basic naming and create date…