Saafia NM

Saafia NM

  • NA
  • 52
  • 11.2k

SQL command to get two row values in single row

Feb 16 2016 2:24 AM
 TableName:Upload
 ID Keyword
 1116Dot Net 
 2836 Dot Net
 5636 Dot Net
 
TableName:Index_list (Resultant Table)
 ID Keyword
 1116,2836,5636 Dot Net
 
 Sir i need the sqlcommand query to get resultant table in asp .net(c# language)
I tried the following command,but it gives the result  same as Upload table.
 
SqlCommand cmnd= new SqlCommand("select Upload.Keyword,ID=replace((select ID as [data()] from Index_list where Index_list.Keyword=Upload.Keyword order by ID for XML PATH('')),'',',') from Upload group by Keyword", con);
it works in SQL Server Management Studio,but not in Visual Studio 2012 sqlcommand .Please help.....
 

Answers (14)