Solved

SQL Split character from numbers

Posted on 2016-11-29
3
62 Views
Last Modified: 2016-11-29
Looking to split VFPNO00007654 into VFPNO 00007654
example  2 VSDN00002345 into VSDN 00002345

Any help much appreciated
0
Comment
Question by:Mauro Cazabonnet
[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 34

Accepted Solution

by:
ste5an earned 500 total points
ID: 41905842
Use PATINDEX and SUBSTRING:

DECLARE @Sample TABLE
    (
      AlphaNumeric NVARCHAR(255)
    );

INSERT  INTO @Sample
VALUES  ( N'VFPNO00007654' ),
        ( N'VSDN00002345' );

SELECT  S.AlphaNumeric ,
        PATINDEX('%[0-9]%', S.AlphaNumeric) ,
        SUBSTRING(S.AlphaNumeric, 1, PATINDEX('%[0-9]%', S.AlphaNumeric)) ,
        SUBSTRING(S.AlphaNumeric, PATINDEX('%[0-9]%', S.AlphaNumeric), 1024)
FROM    @Sample S;

Open in new window

1
 
LVL 50

Expert Comment

by:Vitor Montalvão
ID: 41905845
Are those variables or table columns?
Do you want to split them in 2 variables/columns or add a single space between them?
The rule is to split at the first zero or any number?
0
 
LVL 4

Author Closing Comment

by:Mauro Cazabonnet
ID: 41905876
Stefan,
Awesome thx.......
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

705 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