SQLServer- How to pass select Query with ',' in it

61 views Asked by At

I have a select query which I want to pass as @sql parameter- but I am getting error with syntax in ',' so how to avoid that and pass [','] in sql statement.

I am using SQLServer

select SERVER_ID,
  replace(stuff((SELECT STATUS+ ', ' + cast(SERVER_NAME as varchar(25))
       FROM twx_server_details 
       where SERVER_ID = t1.SERVER_ID
       FOR XML PATH('')),1,0,''),',', CHAR(13),CHAR(10))
from twx_server_details t1
group by SERVER_ID 
0

There are 0 answers