select stuff((select ','+w.Waybillno from Web_Way_Waybill w where w.IsValid<>'Y' AND w.TruckOrder='T1712220007' FOR XML PATH('')),1,1,''))+ left(',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,', (59- (select len(( select stuff((select '…