Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 question

Author  Topic 

kote_alex
Posting Yak Master

112 Posts

Posted - 2009-06-05 : 05:50:36
how can I select a column but I have some unwanted letters in my select ... like these

ROCNP 2661201354755
ROCNP 1691209052867
ROCNP 2790426253200
ROCNP 2800929115178


how can I select only the numbers ? without the ROCNP ?

raky
Aged Yak Warrior

767 Posts

Posted - 2009-06-05 : 06:02:22
select LTRIM(replace(column,'ROCNP,''))
FROM TABLE
Go to Top of Page

kote_alex
Posting Yak Master

112 Posts

Posted - 2009-06-05 : 09:48:06
it worked ! thanks !!!

but now how can I make a select from that select ?

because like this it doesn't work

select LTRIM(replace(T1.Codfiscal,'RO',' ') from

( select LTRIM(replace(Codfiscal,'ROCNP',' ')) FROM a_temp ) T1
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-05 : 10:11:25
What is your wanted output?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-06-05 : 10:19:15
try this

select LTRIM(replace(T1.Codfiscal,'RO',' ') from

( select LTRIM(replace(Codfiscal,'ROCNP',' ')) as Codfiscal FROM a_temp ) T1

and go through Replace Function in sql server.You will get answers to your queries.
Go to Top of Page

kote_alex
Posting Yak Master

112 Posts

Posted - 2009-06-05 : 10:22:09
as I said before I have unwanted char in my column... 4 to 5 letters stacked together with numbers ... so from RO3245667 and rocnp32545456 and ror2356677 ... i just want to filter the numbers without the letters ... and I have to make multiple selects but with only one column output .
Go to Top of Page

kote_alex
Posting Yak Master

112 Posts

Posted - 2009-06-05 : 10:23:47
quote:
Originally posted by raky

try this

select LTRIM(replace(T1.Codfiscal,'RO',' ') from

( select LTRIM(replace(Codfiscal,'ROCNP',' ')) as Codfiscal FROM a_temp ) T1

and go through Replace Function in sql server.You will get answers to your queries.



thanks... it worked... :D
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-06-05 : 11:42:40
welcome...
Go to Top of Page
   

- Advertisement -