Hi all,
I'm trying to search in a column and remove a comma and what comes before
it.
like this: AL, Alabama
FL, Florida
then should look like this
Alabama
Florida
trying to use the replace with wild card but doesn't seam to work?
Any ideas?
update statetbl
set ColumnState = replace(ColumnState ,'*,','')
Thanks
gvHi gv,
you sure can write a function for that, but in common, that should be
something like this solution:
DECLARE @.MyString varchar(200)
SET @.MyString = 'AL, Alabama'
SELECT
SUBSTRING(@.MyString,CHARINDEX(',',@.MyStr
ing)+2,LEN(@.MyString)-CHARINDEX(',',
@.MyString))
HTH, Jens Suessmeyer.|||There is no wildcard support for the replace function.
Couple of ways:
-- if always in 'ST, State' format
update statetbl
set ColumnState = substring(ColumnState,5,50)
-- if not
update statetbl
set ColumnState = ltrim(replace(ColumnState, left(ColumnState,
charindex(',', ColumnState)), ''))
gv wrote:
>Hi all,
>I'm trying to search in a column and remove a comma and what comes before
>it.
>like this: AL, Alabama
> FL, Florida
>then should look like this
> Alabama
> Florida
>trying to use the replace with wild card but doesn't seam to work?
>Any ideas?
>update statetbl
>set ColumnState = replace(ColumnState ,'*,','')
>Thanks
>gv
>
>|||Thanks everyone!!!!
gv
"gv" <viatorg@.musc.edu> wrote in message
news:O2chham2FHA.2796@.tk2msftngp13.phx.gbl...
> Hi all,
> I'm trying to search in a column and remove a comma and what comes before
> it.
> like this: AL, Alabama
> FL, Florida
> then should look like this
> Alabama
> Florida
> trying to use the replace with wild card but doesn't seam to work?
> Any ideas?
> update statetbl
> set ColumnState = replace(ColumnState ,'*,','')
> Thanks
> gv
>sql
No comments:
Post a Comment