Whippingboy2004
Technical User
I'm using a cursor to concatenate the values of a one-to-many relationship into a single column. See I read the FAQ's, specifically faq 183-2146! What I'm having an issue with is the comma separating each value. Depending on my placement of the comma in the statement, I get either an extra trailing or preceding comma that's superfluous.
Ex. , x, y, z
OR
x, y, z,
WHILE @@Fetch_Status=0
BEGIN
IF @CurrKey <> @PrevKey
IF @PrevKey !=-1
BEGIN
INSERT #Concat
VALUES(@PrevKey, @BigLine)
SET @BigLine=''
END
SET @PrevKey=@CurrKey
SET @BigLine=(@BigLine+'')+(@CurrLine+', ') --These are the two possibilities I've tried.
--SET @BigLine=(@BigLine+', ')+(@CurrLine)
SET
FETCH myCursor INTO @CurrKey, @CurrLine
END
This is probably something fairly simple to accomplish, but I just can't see it right now.
Thank you in advance for you help,
T.
Ex. , x, y, z
OR
x, y, z,
WHILE @@Fetch_Status=0
BEGIN
IF @CurrKey <> @PrevKey
IF @PrevKey !=-1
BEGIN
INSERT #Concat
VALUES(@PrevKey, @BigLine)
SET @BigLine=''
END
SET @PrevKey=@CurrKey
SET @BigLine=(@BigLine+'')+(@CurrLine+', ') --These are the two possibilities I've tried.
--SET @BigLine=(@BigLine+', ')+(@CurrLine)
SET
FETCH myCursor INTO @CurrKey, @CurrLine
END
This is probably something fairly simple to accomplish, but I just can't see it right now.
Thank you in advance for you help,
T.