Doug Lubey and Family

Home     About Me     Contact Me     Site Map     Pictures     TESTGOOGLEFORM      
REVIEW DVD MENU WITH MORE
Delete Carriage Returns f
SQL COMMENTS IN SQL MANAG
Sharepoint TaskLists Cust
Moss 2007 Print Screen
SQL SERVER 2005 nvarchar(
transact sql performance
ExchangeDistributionGroup
JavaScriptHowToDetectOper
PayPalNameValuePairs
SQL DAtabase Columns Name
DFS FOLDER CREATED ON WIN
various DFS Errors
ADOBE FLEX AND DOTNET XML
sql 2005 stored procedure
SERVER 2008 CAN NOT VIEW
PowerPointToDvdMpeg2Creat
Dynamically_Generate_Inli
Horizontal Div Tag Alignm
Jquery_WCF4_JSON_webConfi
wcf4 services https bindi
COALESCE sql statement si
2012-01-24
 
I have used the Coallace statement multiple times in SQL to rollup several records into a single Variable.  This variable eventually gets utilized in a PivotTable Crosstabe query.
 
Well this time:  I had new need.
 
Rollup several record ID numbers into a singled field whcih saparates the Id with a comma (delimeter).
 
Very easy to do; If you use other tools SQL 2008 R2 provides.
 
 
This is exactly What I needed:
===================================================
  select distinct
 Courseid
 ,relationalRecords = (select cast(AdvertiseId as varchar)+',' from
                         CourseAdvertising where CourseAdvertising.Courseid=Courses.Courseid for XML path(''))
  from Courses
 
 
REFERENCE:
rollup table COALESCE sql statement single comma delimited with multiple records
sql select statement relational records comma delimited
with out using a cursor or temporary table or with out using SET STATEMENTS or VARIABLES
 
 
I originally found the how to here: