Solved

String Function

Posted on 2015-01-27
3
86 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
3 Comments
 
LVL 32

Assisted Solution

by:Daniel Wilson
Daniel Wilson earned 250 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 250 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
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.

828 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