You can do this easily in SQL Server...assumming you have SQL 2000 here is
one way using a UDF.

Usage: dbo.listGetAt(list, position, delimiter)
This function returns the value at the position requested.  Requesting a
position that is larger than the length of the list will return NULL.
Example:  dbo.listGetAt('1,2,3,4', 3, ',') returns 3.

I have a whole host of List Functions if you want them...including:

listAppend 
listDeleteAt 
listFirst
listGetAt
listInsertAt
listLast 
listLen 
listPrepend
listSetAt 
listToTable


===============================

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO


CREATE FUNCTION listGetAt(@list as varchar(8000), @pos as int, @delim as
varchar(10))
RETURNS varchar(255)
AS
BEGIN
        declare @retval varchar(255)
        if @pos > dbo.listLen(@list, @delim) OR @pos < 1
                set @retval = NULL
        else
        begin
                declare @myPos int
                set @myPos = 1

                while @myPos < @pos
                begin
                        set @myPos = @myPos + 1
                        set @list = right(@list, len(@list) -
charindex(@delim, @list))
                end
                set @retval = @list
                if charindex(@delim, @retval) > 0
                        set @retval = left(@retval, charindex(@delim,
@retval) - 1)
        end

        return @retval
END

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
==================================


-----Original Message-----
From: Che Vilnonis [mailto:[EMAIL PROTECTED] 
Sent: 27 April 2005 15:25
To: CF-Talk
Subject: RE: ListGetAt in a SQL Select Statement... is this possible?

Hopefully... I asked this once before a couple of years ago, but frankly,
the solution was a little difficult for me to figure out.

-----Original Message-----
From: Aaron Rouse [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 27, 2005 10:17 AM
To: CF-Talk
Subject: Re: ListGetAt in a SQL Select Statement... is this possible?

This e-mail is from Reed Exhibitions (Oriel House, 26 The Quadrant,
Richmond, Surrey, TW9 1DL, United Kingdom), a division of Reed Business,
Registered in England, Number 678540.  It contains information which is
confidential and may also be privileged.  It is for the exclusive use of the
intended recipient(s).  If you are not the intended recipient(s) please note
that any form of distribution, copying or use of this communication or the
information in it is strictly prohibited and may be unlawful.  If you have
received this communication in error please return it to the sender or call
our switchboard on +44 (0) 20 89107910.  The opinions expressed within this
communication are not necessarily those expressed by Reed Exhibitions.
Visit our website at http://www.reedexpo.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204670
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to