0

SQL Server convert select a column and convert it to a string

Is it possible to write a statement that selects a column from a table and converts the results to a string? Ideally I would want to have comma separated values. For example, say that the SELECT statement looks something like.....

You can do it like this: 🖖

declare @results varchar(500)

select @results = coalesce(@results + ',', '') +  convert(varchar(12),SttRec)
from CNPhaiTra_HoaDonMuaHang
WHERE RowId in (70,74)

select @results as results

Good Luck


All rights reserved

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí