I am extracting the first part of column in SQL Server using substring
to get an order number, however some of the data has a comma after it which I would also like to remove.
This is what I'm using to extract the order number:
SUBSTRING([Column], 1, CHARINDEX(' ', [Column])) AS OrderNbr
A couple of the values are being extracted as '01234,' or '02348,'
Is there a way I can remove the comma from the data. I tried using replace but wasn't able to combine it with SUBSTRING
:
REPLACE([Column], ',', ' ') AS test
1条答案
按热度按时间xxhby3vn1#
I think you actually can combine substring and replace like this :