Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Posts
    223

    Unanswered: How to specify output format

    Hello everyone:

    There is query output like:
    1
    2
    3
    4

    How to specify it to be like"
    1,2,3,4
    ?
    Thanks

    ZYT

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Code:
    USE Northwind
    GO
    
    SET NOCOUNT ON
    CREATE TABLE myTable99(Col1 char(1))
    GO
    
    INSERT INTO myTable99(Col1)
    SELECT '1' UNION ALL SELECT '2' UNION ALL SELECT '3' UNION ALL SELECT '4'
    GO
    
    SELECT * FROM myTable99
    
    DECLARE @x varchar(100)
    
    SELECT @x = COALESCE(@x + ', ','') + Col1 FROM myTable99
    
    SELECT @x
    GO
    
    SET NOCOUNT ON
    DROP TABLE myTable99
    GO
    Check out

    http://www.sqlteam.com/item.asp?ItemID=2368
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •