Explaination of basic SQL Server Code I found. Original credited in comments