SQL max command

I have the follwoing data in the table.

wID
WS-1000
IS-1001
MS-10001

Two letters, a hyphen then number 4 to 5 digits. How can I select the maximum number from the digit part?

thanks

ayha
LVL 7
ayha1999Asked:
Who is Participating?
 
s_chilkuryConnect With a Mentor Commented:
Try:
SELECT @NId = MAX(CAST(SUBSTRING(field, 4, len(field)) as INT))  FROM [table];
0
 
ayha1999Author Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.