select Item_ id, stuff((SELECT distinct ', ' + cast(Item as varchar(10)) FROM Table_Items t2 where t2.Item_ id= t1.Item_ id FOR XML PATH('')),1,1,'') as Item from Table_Items t1 group by Item_ id
// if you fetch all data from sql table into DataTabl dt; then use this logic //otherwise use Solution 1 DataTable dt = new DataTable(); string item_id = string.Empty; DataRow[] datarows = dt.Select("item_id = '" + item_id + "'"); string result = item_id; foreach (DataRow dr in datarows) { result += "," + dr["Item"].ToString(); } //you can use result; //TODO: Console.WriteLine(result);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)