Click here to Skip to main content
15,888,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi How Extract 1 Column as 2 columns in sql

for ex: GP100 is devide into GP and 100
GPS20 is devide into GPS and 20



please help me
Posted

Create below function
SQL
Create Function [dbo].[RemoveNonAlphaCharacters](@Temp VarChar(1000))
Returns VarChar(1000)
AS
Begin

    Declare @KeepValues as varchar(50)
 set @KeepValues= '%[^a-z]%'
    While PatIndex(@KeepValues, @Temp) > 0
        Set @Temp = Stuff(@Temp, PatIndex(@KeepValues, @Temp), 1, '')

    Return @Temp
End

now run this query
SQL
with a as
(
select 'GP100' as no1
union all
select 'GPS120'
)
Select no1, dbo.RemoveNonAlphaCharacters(no1) alphabets,replace(no1,dbo.RemoveNonAlphaCharacters(no1),'') nos from a

Happy Coding!
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900