June 26, 2009 at 6:30 am
Hi everybody, i have a column with values looking like this 'pp_uniline_usd:Entity', how do i remove the ':Entity' part of the string?
e.g
this...
'pp_uniline_usd'
instead of this...
'pp_uniline_usd:Entity'
Merci:-)
June 26, 2009 at 6:39 am
sorry people, being very silly today...
just used the REPLACE function:w00t:
June 26, 2009 at 6:39 am
Usually, one would use a combination of the following SQL features:
LEFT or SUBSTRING
CHARINDEX or PATINDEX
REPLACE or STUFF
See String Functions
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
June 26, 2009 at 6:50 am
Hi,
If ':Entity' is common among all the values then
select left(columnname,len(substring(columnname,1,charindex(':',extra)-1))) from tablename
please try this
create table #chk(colm varchar(30))
insert into #chk
select 'pp_uniline_usd:Entity' union all
select 'dfsdafsdfsdaf:Entity' union all
select 'dfsdafsdfsdaf:Entity' union all
select 'ffff:Entity'
select left(colm,len(substring(colm,1,charindex(':',colm)-1))) from #chk
drop table #chk
I hope i'm close enough
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply