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
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
April 7, 2022 at 10:26 pm
April 8, 2022 at 5:03 am
This was removed by the editor as SPAM
April 25, 2022 at 1:09 pm
This was removed by the editor as SPAM
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply