首先是源數據:spa
select (CONVERT(varchar(100),cip.CheckIn_StartTime, 23)+' - '+CONVERT(varchar(100),cip.CheckIn_EndTime, 23)+' '+CONVERT(varchar(100),cip.Rental_Price)) as content from CheckInPeriod cip
而後咱們加上合併語句:code
select Stuff((select ',' +Convert(varchar(255),content) from ( select (CONVERT(varchar(100),cip.CheckIn_StartTime, 23)+' - '+CONVERT(varchar(100),cip.CheckIn_EndTime, 23)+' '+CONVERT(varchar(100),cip.Rental_Price)) as content from CheckInPeriod cip ) tba for XML path('')),1,1,'') as content
結果就是這樣的:blog
能夠自定義各類符號。ip