Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8601167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:46:49+00:00 2026-06-12T01:46:49+00:00

I have some varchar data that has numeric values in it, and I’m trying

  • 0

I have some varchar data that has numeric values in it, and I’m trying to strip out only the numeric part. I’m doing this as part of a stored proc that is doing a lot of other stuff at the same time, so I’m hoping to do this as part of an inline query.

My data values in this column look like this (added single ticks to show ends of varchars):

'1.25', '< 5 min', '2.35 minutes', '50.43 min'

What I want to get out of this column is:
1.25, 5, 2.35, 50.43

What my problem seems to be is how to determine the length of the numeric values in the single select, so I can lop off the characters at the end. Other than just choosing a value (my numbers are not always the same length), I’m not sure what I can do. My reason for wanting the numeric value only is because I need to convert it to a float for its destination value.

Here’s what I’ve tried:

 SUBSTRING(my_data, PATINDEX('%[0-9]%', my_data), 4)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:46:50+00:00Added an answer on June 12, 2026 at 1:46 am

    It’s a little complicated, but it works for your examples.

    declare @val varchar(10)
    select @val='50.43 min'
    select 
      case
         when PATINDEX('%[a-z]%',col) = 0
           then col
         else rtrim(SUBSTRING(col,1,PATINDEX('%[a-z]%',col)-1))
       end        
    from
     ( select SUBSTRING(@val,PATINDEX('%[0-9]%',@val),PATINDEX('%[0-9]%',@val)
       +len(@val)+1) as col ) t
    

    Here you can find documentation about string functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a column TypeCode varchar(20) that has values like '1', '2', '3', 'FOO',
I'm having some trouble comparing values found in VARCHAR fields. I have a table
I have some arbitrary pixel data that I want to save as a PNG.
I have a big fat query that's written dynamically to integrate some data. Basically
I have some XML data stored in a varchar(max) column on SQL Server 2005.
I have data in my database that looks like this: Date (DateTime) Type (varchar)
I have some code that pulls data from a mysql db everything is pulling
I have a large table containing some 15 million row, all varchar data. I
I have a JIRA environment which already has some information and i'm trying to
i have some data in my table when i select that data with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.