Answer the question
In order to leave comments, you need to log in
How to convert string '5$' to number?
Zdarov)
I have several fields in the table where records of this kind are '5$', '15$', '24$'.
I need to sort the data by records where it is a string no more than '18$'.
How to convert such a record to a number so that sorting can be done?
Answer the question
In order to leave comments, you need to log in
for example, use cast, after clearing non-numeric characters, for example, using replace
DECLARE @Test TABLE ( S VARCHAR(5))
INSERT @Test VALUES ('5$'), ('15$'), ('24$')
SELECT S FROM @Test WHERE RIGHT( '00' + S, 3 ) < '18$'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question