dbTalk Databases Forums  

QUERY

microsoft.public.sqlserver.mseq microsoft.public.sqlserver.mseq


Discuss QUERY in the microsoft.public.sqlserver.mseq forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Phil
 
Posts: n/a

Default QUERY - 02-04-2004 , 12:22 PM






Hi All

It's getting to the end of the day and there is something
that I just dont seem to be able to figure out.

I have a number of address

Example Below

3 High Street, Chester,
4 The Main Road, Liverpool,

and they have trailing comma's, is there a easy way to get
rid of these.

Any help would be great.

Thanks Phil

Reply With Quote
  #2  
Old   
Ray Higdon
 
Posts: n/a

Default Re: QUERY - 02-05-2004 , 05:03 AM






If you want to get rid of the commas , you can do this

update table set address = replace(address, ','.'')
where address like '%,%'

If you only wanted to get rid of the trailing comma, do this

where address like '%,'

HTH

--
Ray Higdon MCSE, MCDBA, CCNA
---
"Phil" <harlequintp (AT) blazemail (DOT) com> wrote

Quote:
Hi All

It's getting to the end of the day and there is something
that I just dont seem to be able to figure out.

I have a number of address

Example Below

3 High Street, Chester,
4 The Main Road, Liverpool,

and they have trailing comma's, is there a easy way to get
rid of these.

Any help would be great.

Thanks Phil



Reply With Quote
  #3  
Old   
Vishal Parkar
 
Posts: n/a

Default RE: QUERY - 02-05-2004 , 02:21 PM



hi phil,

see following example and use the update statement that has been shown, if satisfies your requirement.

--table/sample data

create table #t(address varchar(50))

--sample rows
insert into #t
select '3 High Street, Chester,' union all
select '4 The Main Road, Liverpool,' union all
select '5 The Main Road, Liverpool1'

--required update statement will be

update #t set address = left(address, len(address) -1)
where address like '%,'


-Vishal

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.