Results 1 to 16 of 16

Thread: [RESOLVED] trying to replace function something not working

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Resolved [RESOLVED] trying to replace function something not working

    hey
    im trying to remove a currenct symbol from a filed
    im missing something in my code
    need some help please
    if the address field contains this '/' then replace it with a empty string
    Code:
    select [Address] as Address,REPLACE([Address],'/','')  from customers
    tnx for any help
    salsa

  2. #2
    Lively Member
    Join Date
    Nov 2020
    Posts
    67

    Re: trying to replace function something not working

    It looks like a query, if it is you have to write it like this:
    Code:
    SELECT Replace(Address. '/', '') As Address FROM customers

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: trying to replace function something not working

    not working amigo
    still i can see the the symbo'/' in the adress field
    example
    sunsent blv 9/12
    need to be
    sunset blv 912

  4. #4

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: trying to replace function something not working

    table name - Customers field name - Adress

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: trying to replace function something not working

    This is a SQL question and has absolutely nothing to do with VB.NET. SQL questions belong in the Database Development forum. I have asked the mods to move this thread.

    You should also specify what database you're using because syntax may vary from one to another.

  6. #6
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: trying to replace function something not working

    This doesn't look right:

    Address.

    Why the period? Maybe a comma?
    Please remember next time...elections matter!

  7. #7

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: trying to replace function something not working

    Quote Originally Posted by TysonLPrice View Post
    This doesn't look right:

    Address.

    Why the period? Maybe a comma?
    also dosnt work
    Code:
    SELECT Replace(Address,'/', ' ') As Address FROM customers

  8. #8
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: trying to replace function something not working

    I think it is probably pilot error:

    create table #Customers(address varchar(10))
    insert into #Customers(address) values('123 / 456')
    SELECT Address As Address FROM #customers
    SELECT Replace(Address,'/', ' ') As Address FROM #customers
    drop table #Customers
    Please remember next time...elections matter!

  9. #9
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,900

    Re: trying to replace function something not working

    Moved to DB section

    Your syntax looks correct.

    Are you getting any error messages? Is this TSQL (SQLServer)? Can you show us the result your query is giving you?
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  10. #10

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: trying to replace function something not working

    Quote Originally Posted by FunkyDexter View Post
    Moved to DB section

    Your syntax looks correct.

    Are you getting any error messages? Is this TSQL (SQLServer)? Can you show us the result your query is giving you?
    NO ERROR friend.
    it just dosnt do anything
    example
    sunsent blv 9/12
    need to be
    sunset blv 912
    table name - Customers field name - Adress

  11. #11
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: trying to replace function something not working

    You are doing something wrong you are not showing us. It works!!! At least on Microsoft SQL Server. What are you using?


    create table #Customers(address varchar(30))
    insert into #Customers(address) values('sunsent blv 9/12')
    SELECT Address As Address FROM #customers
    SELECT Replace(Address,'/', ' ') As Address FROM #customers
    drop table #Customers
    Please remember next time...elections matter!

  12. #12
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: trying to replace function something not working

    Maybe you mean the extra space? Take it out:

    Replace(Address,'/', '')
    Please remember next time...elections matter!

  13. #13
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: trying to replace function something not working

    Are you trying to SELECT from the table and display it ... or UPDATE the data in the table (so that later selects will have the correct data)?


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  14. #14

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: trying to replace function something not working

    Quote Originally Posted by techgnome View Post
    Are you trying to SELECT from the table and display it ... or UPDATE the data in the table (so that later selects will have the correct data)?


    -tg
    UPDATE the data in the table (so that later selects will have the correct data)?
    replace and update

  15. #15
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: trying to replace function something not working

    I'm done pulling teeth
    Please remember next time...elections matter!

  16. #16
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: [RESOLVED] trying to replace function something not working

    So... try an UPDATE statement then... SET the Address to the replaced values...

    It's not that hard.
    UPDATE someTable
    SET someField = someValue
    Where SomeCondition

    If you want to update all the rows in the table, don't have a where clause. Just the update and set.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width