SQLTeam.com | Weblogs | Forums

Combine columns of type real


#1

How can I combine five columns of type real into one column ( also of type real)?

I have tried the following :

   update Vragte_Vyfjaar_Histories set suiker = concat(suiker_min5, suiker_min4,suiker_min3,suiker_min2,suiker_min1)

Four of the column will always be zero. My problem with the above is that in the case where there is no trailing values after the comma. the command does not work. ( eg 34 0 0 0 0 column values have the following result : 34000). Other columns does work ( eg. 25.1 0 0 0 0 have the result 25.1).

Any help would be much appreciated.

regards


#2

e.g.

declare @r real = 3.14159
declare @e real = 2.718
declare @n real = nullif(0, 0)

select concat(@r,@e, @n)

yields:

3.141592.718


#3

If four of them are always zero, why not just add them?!

UPDATE Vragte_Vyfjaar_Histories
SET suiker = suiker_min5 + suiker_min4 + suiker_min3 + suiker_min2 + suiker_min1


#4

Thank you Scott. I've been complicating things to much.