Solved

String Function

Posted on 2015-01-27
3
79 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 14

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now