April 7, 2022 at 1:22 am
I have such an issue.
On column namely t.DC has sometimes other values after the number for example
01 ROYAL
40 ABC
Trying to see if there is anything that can erase those names after digits leaving just the numbers there.
`
select t.Chain, t.DC, t.Item#
FROM t
`
When I try to write like this " CASE WHEN t.DC IN (01, 02, 08, 21, 22, 30, 32, 40, 55, 62) THEN t.DC ELSE '01' END AS DC," I am getting an error " Conversion failed when converting the nvarchar value '21 CE' to data type int."
April 7, 2022 at 6:44 am
Try this:
CASE WHEN LEFT(t.DC,2) IN ('01', '02', '08', '21', '22', '30', '32', '40', '55', '62')
THEN LEFT(t.DC,2)
ELSE '01'
END AS DC
April 7, 2022 at 10:26 pm
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply