How to Find Greater Than of an Alphanumeric Number

0

Please login or register to vote for this query.

(click on this box to dismiss)

Engineering

Q&A for professionals and students of engineering

declare @tbl as table(SalesOrderNo varchar(10));
insert into @tbl values
('1'),
('2'),
('D1'),
('D2'),
('D11'),
('D12'),
('D16'),
('D20'),
('D21');

select SalesOrderNo from @tbl
where SalesOrderNo LIKE 'D%'
and cast(right(SalesOrderNo, len(SalesOrderNo) - 1) as int) > 16;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results