February 5, 2015 at 1:55 pm
Hi,
I have a simple statement where I am trying to remove all commas that may be in the xn_workordeld column.
SELECT
xn_workordeld = case replace(xn_workordeld, ',', '') as "WORKORDER LD"
from workorder
But I'm not having much luck ...doing something wrong.
February 5, 2015 at 2:05 pm
krypto69 (2/5/2015)
Hi,I have a simple statement where I am trying to remove all commas that may be in the xn_workordeld column.
SELECT
xn_workordeld = case replace(xn_workordeld, ',', '') as "WORKORDER LD"
from workorder
But I'm not having much luck ...doing something wrong.
Try this:
SELECT
REPLACE(CAST(xn_workordeld AS VARCHAR(MAX)),',', '') AS 'WORKORDER LD'
from workorder
February 5, 2015 at 3:43 pm
krypto69 (2/5/2015)
Hi,I have a simple statement where I am trying to remove all commas that may be in the xn_workordeld column.
SELECT
xn_workordeld = case replace(xn_workordeld, ',', '') as "WORKORDER LD"
from workorder
But I'm not having much luck ...doing something wrong.
Two things are wrong:
- You're asigning a column name twice. Once using the equal sign and the other using AS keyword.
- You also have a case keyword without the complete structure.
I'm not sure if those errors are in your real code, but if you remove them it works fine.
WITH workorder AS(
SELECT 'some, commas, in, here,' AS xn_workordeld
)
SELECT replace(xn_workordeld, ',', '') as "WORKORDER LD"
from workorder
February 5, 2015 at 4:37 pm
thanks guys!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply