Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: pre-process alphanumeric field Post Reply Post New Topic
Author Message
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Topic: pre-process alphanumeric field
     Posted: 18 Jun 2009 at 5:28am
Hi
 
I intend to pre-process alphanumeric fields on the SQL 2005 server before reporting.
I have some strings like below:
I_CNO (field)
TR 004.
ENGLISH
REF 581
F
BIG 912
F
HOME EC
HOME EC
F ALL
F MEE
F MAL
REF 581
B MCB
ENGLISH
Student
ENGLISH
HOME EC
HOME EC
ENGLISH
F
F
F
ART 705
ART 705
HOME EC
F RAB
F
HOME EC
B ROL
B ROL
REF A80

REF 581
B HIL
REF 632
F
F
BIG 912
HOME EC
Student
REF 635
REF 635
HOME EC
F
DRAMA A
PAM 636
HOME EC
HOME EC
HOME EC
HOME EC
TEXT
B DIR
B NOR
F
BIG 919
BIG 919
BIG 919
I wish to move those prefix characters(varied in length) before the first space to another field in the same row.
First I use a select state to see how it goes:

select substring(I_CNO,1, charindex('[A-Z]',I_CNO )+7) FROM SPY_I WHERE ISNUMERIC(substring(I_CNO,1,5)) = 0 and I_CNO IS NOT NULL

 but result doesn't look good.
Could any SQL expert please advise how to write a suitable SQL to achieve my goal? Thanks in advance.
 
John 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 18 Jun 2009 at 6:38am
if you want to move the strings before the spaces why not look for them.
 
select left(i_cno, charindex(' ', i_cno)) from spy_i where charindex(' ',i_cno) <> 0.
 
 
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 19 Jun 2009 at 12:15am
Hi DBlank,
 
Thank you, I made some change of your version by 'Where isnumric(left(i_cno, charindex(' ', i_cno)) = 0 ' as I intend to get A-Z only, not numeric
 
Regards,
John
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum