T-SQL: Column values conversion into one string

Поділитися
Вставка
  • Опубліковано 10 гру 2024
  • DECLARE @TABLE2 TABLE
    (DT datetime,
    PERSON_ID int,
    PRODUCT_NAME nvarchar(200),
    QUANTITY decimal(18,2),
    PRICE decimal(18,2))
    INSERT INTO @TABLE2 VALUES
    ('2018-07-01',1,'TABLE 40x60',50,32.55),
    ('2018-07-02',4,'TABLE 100x60',10,65.00),
    ('2018-07-02',2,'CHAIR X1',30,15),
    ('2018-07-03',4,'CHAIR X2',20,13),
    ('2018-07-03',1,'PC IBM',10,800),
    ('2018-07-04',5,'PC HP',10,720.12),
    ('2018-07-04',4,'PC DELL',8,950)
    SELECT
    PRODUCT_NAME + ' ' as 'data()'
    FROM @TABLE2
    FOR XML PATH ('')

КОМЕНТАРІ •