 |
|
 |
|
Next: Need Help for Parent Child Table Join Output
|
| Author |
Message |
External

Since: Sep 09, 2010 Posts: 3
|
(Msg. 1) Posted: Thu Sep 09, 2010 11:51 am
Post subject: Extracting Data Archived from groups: microsoft>public>sqlserver>programming (more info?)
|
|
|
Hi.
I need some help on extracting certain data from a field.
For example I want to extract anything after the CVC-IBM or CVC-
Covance
CVC-IBM HARROGATE
CVC-COVANCE EMEA
So the column field would be
HARROGATE
EMEA
Can this be done?
Any help is appreciated.
Thanks. >> Stay informed about: Extracting Data |
|
| Back to top |
|
 |  |
External

Since: Dec 03, 2008 Posts: 5
|
(Msg. 2) Posted: Thu Sep 09, 2010 12:46 pm
Post subject: Re: Extracting Data [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Sep 9, 2:51 pm, Kru wrote:
> Hi.
>
> I need some help on extracting certain data from a field.
>
> For example I want to extract anything after the CVC-IBM or CVC-
> Covance
>
> CVC-IBM HARROGATE
> CVC-COVANCE EMEA
>
> So the column field would be
> HARROGATE
> EMEA
>
> Can this be done?
>
> Any help is appreciated.
>
> Thanks.
You mean something like this:
SELECT SUBSTRING('CVC-IBM HARROGATE', CHARINDEX('CVC-IBM HARROGATE',
'CVC-IBM') + LEN('CVC-IBM') + 2, 100)
SELECT SUBSTRING('CVC-COVANCE EMEA', CHARINDEX('CVC-COVANCE EMEA',
'CVC-COVANCE') + LEN('CVC-COVANCE') + 2, 100)
Thanks
Carl >> Stay informed about: Extracting Data |
|
| Back to top |
|
 |  |
External

Since: Sep 09, 2010 Posts: 3
|
(Msg. 3) Posted: Thu Sep 09, 2010 12:58 pm
Post subject: Re: Extracting Data [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Sep 9, 3:46 pm, SetonSoftware wrote:
> On Sep 9, 2:51 pm, Kru wrote:
>
>
>
> > Hi.
>
> > I need some help on extracting certain data from a field.
>
> > For example I want to extract anything after the CVC-IBM or CVC-
> > Covance
>
> > CVC-IBM HARROGATE
> > CVC-COVANCE EMEA
>
> > So the column field would be
> > HARROGATE
> > EMEA
>
> > Can this be done?
>
> > Any help is appreciated.
>
> > Thanks.
>
> You mean something like this:
>
> SELECT SUBSTRING('CVC-IBM HARROGATE', CHARINDEX('CVC-IBM HARROGATE',
> 'CVC-IBM') + LEN('CVC-IBM') + 2, 100)
> SELECT SUBSTRING('CVC-COVANCE EMEA', CHARINDEX('CVC-COVANCE EMEA',
> 'CVC-COVANCE') + LEN('CVC-COVANCE') + 2, 100)
>
> Thanks
>
> Carl
Well there are a lot in the database with different locations. Is
there an easier than this? Below is just a glimpse but the column goes
on and on.
CVC-IBM SYDNEY
CVC-IBM SINGAPORE
CVC-IBM PRINCETON
CVC-IBM HARROGATE
CVC-COVANCE EMEA
CVC-IBM PRINCETON
CVC-IBM SHANGHAI
CVC-IBM SHANGHAI
CVC-IBM SHANGHAI
CVC-COVANCE EMEA
CVC-IBM MAIDENHEAD
CVC-COVANCE EMEA
CVC-COVANCE EMEA >> Stay informed about: Extracting Data |
|
| Back to top |
|
 |  |
External

Since: Sep 09, 2010 Posts: 3
|
(Msg. 4) Posted: Thu Sep 09, 2010 1:57 pm
Post subject: Re: Extracting Data [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Sep 9, 4:46 pm, "Tom Cooper" wrote:
> Select Case When YourColumnName Like 'CVC-IBM %' Then
> SubString(YourColumnName, 9, Len(YourColumnName))
> When YourColumnName Like 'CVC-COVANCE %' Then SubString(YourColumnName,
> 13, Len(YourColumnName))
> Else YourColumnName End
> From YourTableName
>
> Tom
>
> "Kru" wrote in message
>
>
> On Sep 9, 3:46 pm, SetonSoftware wrote:
>
>
>
> > On Sep 9, 2:51 pm, Kru wrote:
>
> > > Hi.
>
> > > I need some help on extracting certain data from a field.
>
> > > For example I want to extract anything after the CVC-IBM or CVC-
> > > Covance
>
> > > CVC-IBM HARROGATE
> > > CVC-COVANCE EMEA
>
> > > So the column field would be
> > > HARROGATE
> > > EMEA
>
> > > Can this be done?
>
> > > Any help is appreciated.
>
> > > Thanks.
>
> > You mean something like this:
>
> > SELECT SUBSTRING('CVC-IBM HARROGATE', CHARINDEX('CVC-IBM HARROGATE',
> > 'CVC-IBM') + LEN('CVC-IBM') + 2, 100)
> > SELECT SUBSTRING('CVC-COVANCE EMEA', CHARINDEX('CVC-COVANCE EMEA',
> > 'CVC-COVANCE') + LEN('CVC-COVANCE') + 2, 100)
>
> > Thanks
>
> > Carl
>
> Well there are a lot in the database with different locations. Is
> there an easier than this? Below is just a glimpse but the column goes
> on and on.
>
> CVC-IBM SYDNEY
> CVC-IBM SINGAPORE
> CVC-IBM PRINCETON
> CVC-IBM HARROGATE
> CVC-COVANCE EMEA
> CVC-IBM PRINCETON
> CVC-IBM SHANGHAI
> CVC-IBM SHANGHAI
> CVC-IBM SHANGHAI
> CVC-COVANCE EMEA
> CVC-IBM MAIDENHEAD
> CVC-COVANCE EMEA
> CVC-COVANCE EMEA
Thanks Tom! Would it make difference if the database is a db2? I am
getting errors that it doesn't like the Len function. >> Stay informed about: Extracting Data |
|
| Back to top |
|
 |  |
External

Since: Mar 12, 2004 Posts: 8
|
(Msg. 5) Posted: Thu Sep 09, 2010 4:46 pm
Post subject: Re: Extracting Data [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Select Case When YourColumnName Like 'CVC-IBM %' Then
SubString(YourColumnName, 9, Len(YourColumnName))
When YourColumnName Like 'CVC-COVANCE %' Then SubString(YourColumnName,
13, Len(YourColumnName))
Else YourColumnName End
From YourTableName
Tom
"Kru" wrote in message
On Sep 9, 3:46 pm, SetonSoftware wrote:
> On Sep 9, 2:51 pm, Kru wrote:
>
>
>
> > Hi.
>
> > I need some help on extracting certain data from a field.
>
> > For example I want to extract anything after the CVC-IBM or CVC-
> > Covance
>
> > CVC-IBM HARROGATE
> > CVC-COVANCE EMEA
>
> > So the column field would be
> > HARROGATE
> > EMEA
>
> > Can this be done?
>
> > Any help is appreciated.
>
> > Thanks.
>
> You mean something like this:
>
> SELECT SUBSTRING('CVC-IBM HARROGATE', CHARINDEX('CVC-IBM HARROGATE',
> 'CVC-IBM') + LEN('CVC-IBM') + 2, 100)
> SELECT SUBSTRING('CVC-COVANCE EMEA', CHARINDEX('CVC-COVANCE EMEA',
> 'CVC-COVANCE') + LEN('CVC-COVANCE') + 2, 100)
>
> Thanks
>
> Carl
Well there are a lot in the database with different locations. Is
there an easier than this? Below is just a glimpse but the column goes
on and on.
CVC-IBM SYDNEY
CVC-IBM SINGAPORE
CVC-IBM PRINCETON
CVC-IBM HARROGATE
CVC-COVANCE EMEA
CVC-IBM PRINCETON
CVC-IBM SHANGHAI
CVC-IBM SHANGHAI
CVC-IBM SHANGHAI
CVC-COVANCE EMEA
CVC-IBM MAIDENHEAD
CVC-COVANCE EMEA
CVC-COVANCE EMEA >> Stay informed about: Extracting Data |
|
| Back to top |
|
 |  |
External

Since: Mar 12, 2004 Posts: 8
|
(Msg. 6) Posted: Thu Sep 09, 2010 5:07 pm
Post subject: Re: Extracting Data [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
I think the equivalent DB2 function is LENGTH() - but I don't work with DB2
and could well be wrong. But this is a SQL Server group, you are much
better off asking DB2 questions in a DB2 forum. And if you must ask a DB2
question here - for example if you are trying to access a SQL Server
database from a DB2 database or vice versa - make sure you identify the fact
that you are using a DB2 database.
Tom
"Kru" wrote in message
On Sep 9, 4:46 pm, "Tom Cooper" wrote:
> Select Case When YourColumnName Like 'CVC-IBM %' Then
> SubString(YourColumnName, 9, Len(YourColumnName))
> When YourColumnName Like 'CVC-COVANCE %' Then SubString(YourColumnName,
> 13, Len(YourColumnName))
> Else YourColumnName End
> From YourTableName
>
> Tom
>
> "Kru" wrote in message
>
>
> On Sep 9, 3:46 pm, SetonSoftware wrote:
>
>
>
> > On Sep 9, 2:51 pm, Kru wrote:
>
> > > Hi.
>
> > > I need some help on extracting certain data from a field.
>
> > > For example I want to extract anything after the CVC-IBM or CVC-
> > > Covance
>
> > > CVC-IBM HARROGATE
> > > CVC-COVANCE EMEA
>
> > > So the column field would be
> > > HARROGATE
> > > EMEA
>
> > > Can this be done?
>
> > > Any help is appreciated.
>
> > > Thanks.
>
> > You mean something like this:
>
> > SELECT SUBSTRING('CVC-IBM HARROGATE', CHARINDEX('CVC-IBM HARROGATE',
> > 'CVC-IBM') + LEN('CVC-IBM') + 2, 100)
> > SELECT SUBSTRING('CVC-COVANCE EMEA', CHARINDEX('CVC-COVANCE EMEA',
> > 'CVC-COVANCE') + LEN('CVC-COVANCE') + 2, 100)
>
> > Thanks
>
> > Carl
>
> Well there are a lot in the database with different locations. Is
> there an easier than this? Below is just a glimpse but the column goes
> on and on.
>
> CVC-IBM SYDNEY
> CVC-IBM SINGAPORE
> CVC-IBM PRINCETON
> CVC-IBM HARROGATE
> CVC-COVANCE EMEA
> CVC-IBM PRINCETON
> CVC-IBM SHANGHAI
> CVC-IBM SHANGHAI
> CVC-IBM SHANGHAI
> CVC-COVANCE EMEA
> CVC-IBM MAIDENHEAD
> CVC-COVANCE EMEA
> CVC-COVANCE EMEA
Thanks Tom! Would it make difference if the database is a db2? I am
getting errors that it doesn't like the Len function. >> Stay informed about: Extracting Data |
|
| Back to top |
|
 |  |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|