I am sure that I am missing something since I have been on this same problem for a few days,but...
I have a column in a table that I need to "de-concatenate"
I thought this was working in the past, but now when I view the results and compare them to the field, I am missing the last phrase. The data looks like this:
Heart & vascular health,Health screenings,Cancer detection & treatment,Bone & joint care,Men's health
Here is the code:
Here are the results:
Men's Health is missing from the results.
I can't seem to see where I can change that selection set to get me all of the field.
I started a new thread since this is not related to the earlier problem that I have been having with this.
Any help would be appreciated
I have a column in a table that I need to "de-concatenate"
I thought this was working in the past, but now when I view the results and compare them to the field, I am missing the last phrase. The data looks like this:
Heart & vascular health,Health screenings,Cancer detection & treatment,Bone & joint care,Men's health
Here is the code:
Code:
ALTER FUNCTION dbo.client_health_topics_ind(@ind_cst_ext_key varchar(38))
RETURNS @HealthTopic Table(HealthTopic VarChar(600),ind_cst_key_ext varchar(38))
AS
BEGIN
DECLARE @HealthDescripB TABLE(
HealthDescrip VarChar(600),
ind_cst_key_ext varchar (38)
)
Insert Into @HealthTopic(HealthTopic,ind_cst_key_ext)
Select LTrim(Rtrim(ind_health_topic_of_interest_ext)),
ind_cst_key_ext
From co_individual_ext
WHERE ind_health_topic_of_interest_ext IS NOT NULL
While Exists(Select * From @HealthTopic Where CharIndex(',', HealthTopic) > 0)
Begin
Insert Into @HealthDescripB(HealthDescrip,ind_cst_key_ext)
Select Left(HealthTopic, CharIndex(',', HealthTopic)-1),
ind_cst_key_ext
From @HealthTopic
Where CharIndex(',', HealthTopic) > 0
Update @HealthTopic
Set HealthTopic = LTrim(RTrim(Right(HealthTopic, Len(HealthTopic)-CharIndex(',', HealthTopic))))
END
Insert Into @HealthDescripB(HealthDescrip,ind_cst_key_ext)
Select Replace(HealthTopic, ',', ''),ind_cst_key_ext
From @HealthTopic
RETURN
END
Code:
Heart & vascular health 2A24598A-2B06-482C-824F-00085DF86F97
Health screenings 2A24598A-2B06-482C-824F-00085DF86F97
Cancer detection & treatment 2A24598A-2B06-482C-824F-00085DF86F97
Bone & joint care 2A24598A-2B06-482C-824F-00085DF86F97
I can't seem to see where I can change that selection set to get me all of the field.
I started a new thread since this is not related to the earlier problem that I have been having with this.
Any help would be appreciated