This script will join a single selected column from a select statement into a varchar variable. This works similarly to the javascript join function with a few additional features. By default the values will be joined with commas unless an alternate delimiter is supplied. The user can specify if the delimited values should quoted.
To use this sp only the selected column, the from clause and the where clause are supplied rather than the entire select statement.