[UPDATE: JAN-2017] I moved all the free source code for SQL-Server, that I had previously published on another website of mine, onto this blog, and here is a link that searches this blog for all SQL postings.
Set-Based SQL Procedures Overview
There are also some related MS SQL-Server stored procedures and functions on the main-page of the "library" including routines and functions for splitting and parsing strings, padding numbers to fixed-width, accumulating totals of values within comma-delimited strings, comparing nullable columns, and more. I also posted a series about tuning very large SQL-Server databases for anyone dealing with massive database performance-tuning issues.
I hope you find SQL-Server set-based algorithms, stored-procedures, and functions helpful when tackling common business-requirements. I have used the SQL running-subtotals and moving-averages to implement some neat financial data modeling and analysis software (everyone is used to moving-average stock-prices and such, right?), and the order-by operations without dynamic-SQL have been quite handy on websites (preventing potential security issues associated with dynamic-SQL and SQL-Injection attacks).
Continue to read this Software Development and Technology Blog for computer programming articles (including useful free / OSS source-code and algorithms), software development insights, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, Delphi, Nvidia CUDA, VMware, TypeScript, SVG, other technology tips and how-to's, plus my varied political and economic opinions.