结果前后的刻度

Ticks before and after results

我希望我的查询结果在结果前后有刻度线,中间有逗号:

DECLARE @aracct VARCHAR(12)
SET @aracct = '49944928'
DECLARE @tran_id_pmt VARCHAR(6)
SET @tran_id_pmt = '147317'
SELECT '''',CONVERT(VARCHAR(8), transactions.item_no) AS item_no,'''','' FROM receivables_pmt INNER JOIN transactions
           ON receivables_pmt.tran_id_paid = transactions.tran_id
                WHERE aracct = @aracct AND tran_id_pmt = @tran_id_pmt
                    ORDER BY transactions.item_no


item_no       
---- -------- ---- ----
'    1003     ',    
'    1006     ',   
'    1010     ',  
'    1012     ', 

无论如何这是可能的?

SELECT '''' + LTrim(RTrim(CONVERT(VARCHAR(8), transactions.item_no))) AS item_no + '''','' FROM receivables_pmt INNER JOIN transactions
           ON receivables_pmt.tran_id_paid = transactions.tran_id
                WHERE aracct = @aracct AND tran_id_pmt = @tran_id_pmt
                    ORDER BY transactions.item_no

您需要 trim 转换值以删除空格并使用 (+) 号连接值。