Error 130 says you cannot perform an aggregate function on an expression containing an aggregate, like AVG(COUNT()). A derived table gets around it.
SQL SERVER – Binary Sequence Generator – Truth Table Generator
A script that builds a 512 row truth table with its decimal value and binary sequence, using CROSS JOINs on a bit table. Add or remove joins to resize it.
SQL SERVER – Query to Find First and Last Day of Current Month – Date Function
One query to find the First and Last Day of Current Month in SQL Server, plus the last day of the previous month and the first day of the next.
SQL SERVER – UDF – Function to Parse AlphaNumeric Characters from String
UDF_ParseAlphaChars keeps only the alphanumeric characters in a string and strips everything else using PATINDEX and STUFF. A handy function, with a test.
SQL SERVER – Creating Comma Separate Values List from Table – UDF – SP
Three ways to build a Comma Separate Values List from a table: COALESCE, a smart SELECT, or a cursor. Written for SQL Server 2005 with VARCHAR(MAX).
SQL SERVER – UDF – Function to Convert List to Table
A UDF, udf_List2Table, to convert list to table with any delimiter you choose. Written for SQL Server 2005 with VARCHAR(MAX), and easy to adapt for 2000.
SQL SERVER – UDF – User Defined Function to Find Weekdays Between Two Dates
A user defined function that returns the number of weekdays between two dates, skipping Saturday and Sunday. It was written by Alexander Chigrik.







