Concatenate row values

  • Hi!

    I´ve the table

    USE [labmanager2]

    GO

    /****** Object: Table [dbo].[DESTINATARIO] Script Date: 12/17/2010 14:21:32 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_PADDING ON

    GO

    CREATE TABLE [dbo].[DESTINATARIO](

    [DESTID] [smallint] IDENTITY(1,1) NOT NULL,

    [DESTNOMBRE] [varchar](60) COLLATE Modern_Spanish_CI_AS NULL,

    [DESTEMAIL] [varchar](60) COLLATE Modern_Spanish_CI_AS NULL,

    [TMAILID] [smallint] NULL,

    PRIMARY KEY CLUSTERED

    (

    [DESTID] ASC

    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

    ) ON [PRIMARY]

    GO

    SET ANSI_PADDING OFF

    I need to get all the 'destemail' where tmailid is '11' and the result is concatenated.

    Destnombre destemail tmailid

    Ignacio peralesiperales@matrix.cl 11

    Monica jerezmjerez@matrix.cl 8

    Felipe Ortegafortega@matrix.cl 9

    Edmundo Ruizeruiz@matrix.cl 11

    So i need the uotput to be;

    'iperales@matrix.cl;eruiz@matrix.cl'

    thanks in advance.

  • select destemail + ';'

    from [dbo].[DESTINATARIO]

    where tmailid = 11

    for xml path('');

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply