I have published some of my free source code for SQL-Server (link) online for others to adapt and learn from hopefully.
Set-Based SQL Procedures Overview
I have implemented, using only set-based algorithms (i.e., no database cursors), functionality that many would consider "impossible" without cursors and without dynamic SQL; as such, these techniques may be intriguing and/or useful to other SQL-Server developers, especially web-based applications that need to be secure from SQL-injection attacks. There is no dynamic-SQL used and no cursors used to implement these algorithms — seriously.
The following table provides links to the various free source code for the stored procedures I have published under the terms of the MIT License (for freeware) on my company website's free source code library. All of these techniques have been tested and developed using Microsoft SQL-Server versions: SQL Server 2005, SQL Server 2008, and SQL Server 2008r2.
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).
Enjoy, and let me know what you think.
0 comments:
Post a Comment