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 8115367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:27:30+00:00 2026-06-06T03:27:30+00:00

I have a string like prop234 the alphabet part has fixed length but the

  • 0

I have a string like prop234 the alphabet part has fixed length but the numeric part may be of any length

I have to get the numeric part from the string in T-SQL (on SQL Server 2008)

I tried with SUBSTRING function but I don’t know the length of the numeric part so can’t provide third parameter i.e. length

SUBSTRING ( expression ,start , length )

I know the start index but length can be anything

One solution is

SELECT substring([ColumnName], 5, LEN(ColumnName) - 4)

as start index is fixed i.e. length of alphabet part is 4 (fixed)

Is there any better solution for this and what if the length of alphabetic part is not constant?

  • 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-06T03:27:31+00:00Added an answer on June 6, 2026 at 3:27 am
    select stuff('prop234', 1,4,'')
    

    and if the length is not a constant:

    declare @t table(expression varchar(100))
    insert @t values('propprop234')
    
    select stuff(expression, 1, patindex('%_[0-9]%', expression), '') from @t
    

    EDIT: To make sure bad data is handled, such as no text first or no number last, here is a slightly different approach:

    select stuff(expression, 1,patindex('%[^0-9][0-9]%', expression + '0'), '') 
    from @t 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string like this first#second, and I wonder how to get second part
I have string like this: http://someurl.com?someparameter=dhws6sd6cvg and i would like to mach part from
I have string like this: http://someurl.com?test&lettersg and I would like to mach part from
Have a string like A=B&C=D&E=F, how to remove C=D part and get the string
I have string like /sdcard/filename.pdf Can any one get me the regex to get
Let's presume that I have string like '=&?/;#+%' to be a part of my
How can we divide the substring from the string Like I have string String
I have a string like rdb_master_mongodb where rdb_ is fixed and master is a
I have string like this: command . / * or any other char like
I may have string like, Hello, %(name)s, how are you today, here is amount

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.