Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

String Function

Posted on 2015-01-27
3
Medium Priority
?
101 Views
Last Modified: 2015-01-28
Hello All,
We have a table which has data like below for a column ID
TEST300
TEST301
TEST302
TEST303
TEST304
How to extract data after 'test' like just 300,301,302,303,304.
Please help.
0
Comment
Question by:Star79
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 32

Assisted Solution

by:Daniel Wilson
Daniel Wilson earned 1000 total points
ID: 40573636
Borrowing a bit of code from here ... http://www.experts-exchange.com/Database/Miscellaneous/A_17544-ORDER-BY-a-combined-value-text-numercial.html

I think this code snippet should do:
select cast(substring(ID, patindex('%[0-9]%', ID) , len(ID)) as int) as NumberPortion from MyTable

Open in new window

0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40573671
Substring(ID,5,999)
0
 
LVL 15

Accepted Solution

by:
Vikas Garg earned 1000 total points
ID: 40574473
Hi,

Can try these ways
DECLARE @TS2 VARCHAR(50) = 'TEST'
SELECT SUBSTRING(Column,LEN(@TS2)+1,3),RIGHT(Column,3)

Open in new window

0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question