August 18, 2006 at 8:42 am
Hi there
This query sould produce a single row result. instead of this I have a 3 row result (ie it seems it is not iterating, just looping throu all records
with ip (SYSTEM_ID, IP_ADDRESS) as
(
select distinct IP0.SYSTEM_ID,
cast('' as varchar(400))
from CEPPLUS.IP_INTERFACE IP0
where IP0.SYSTEM_ID = 188
union all
select IP1.SYSTEM_ID,
IP1.IP_ADDRESS + case when IP1.IP_ADDRESS = '' then '' else ', ' end + IP2.IP_ADDRESS
from ip IP1, CEPPLUS.IP_INTERFACE IP2
where IP1.SYSTEM_ID = IP2.SYSTEM_ID
and IP1.IP_ADDRESS = ''
)
select * from ip where IP_ADDRESS != ''
Here is the result:
SYSTEM_ID IP_ADDRESS
188 , 10.168.4.182
188 , 62.184.239.71
188 , 10.168.2.79
instead of the desired
SYSTEM_ID IP_ADDRESS
188 10.168.4.182, 62.184.239.71, 10.168.2.79
Bye
Gabor
August 20, 2006 at 11:19 am
I just posted a similar solution at the following URL
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=23&messageid=302356
look for the function I created...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply