List Function

  • Hello,

    I'm converting a database from Sybase SQL Anywhere 5.5 to MSS 2000. Sybase has a funtion titled list which is used in a few reports. (I've listed the definition below.) Does MSS 2000 have something similar to the list function. Thanks in advance for any assistance.

    LIST( string-expr ) Returns a string containing a comma-separated list composed of all the values for string-expr in each group of rows. Rows where string-expr is the NULL value are not added to the list.

    LIST( DISTINCT column-name) Returns a string containing a comma-separated list composed of all the different values for string-expr in each group of rows. Rows where string-expr is the NULL value are not added to the list.

  • No, not that I'm aware of, at least not built in.

  • There is no direct equivalent in SQL Server. However, in SQL Server 2000, you can create a UDF to emulate this function.

    However, there is an easier way to do this inside the SQL itself. In SQL Server, you can issue a command like:

    Declare @List varchar(4000)

    Set @List = ''

    Select @List = @List + MyDataField + ','

    FROM MyTable

    WHERE CustID = 1

    Select @List

    This will return a comma delimited list. To strip the trailing comma, use:

    Select Left(@List, Len(@List)-1)

  • Thank you for the input. I think the sql solution will help.

Viewing 4 posts - 1 through 3 (of 3 total)

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