Replace Part Of SQL Statementr

  • How do I use a wild card character to replace a string to turn:


    These String
    "SELECT ONE, TWO, THREE FROM TABLE WHERE ID = '1234567'"
    "SELECT TWO, THREE, FIVE FROM TABLE WHERE ID = '7654321'"


    To This
    "SELECT * FROM TABLE WHERE ID = '1234567'"
    "SELECT * FROM TABLE WHERE ID = '7654321"

  • Re: Vba Replace Funtion Wildcard Char


    Quote from Andy Pope

    [vba]
    replace("SELECT ONE, TWO, THREE FROM TABLE WHERE ID = '1234567'","ONE, TWO, THREE","*")
    [/vba]



    i have multiple lines with different find section parts, I have tried
    [vba] replace("SELECT ONE, TWO, THREE FROM TABLE WHERE ID = '1234567'", "SELECT * FROM" ,"SELECT * FROM")[/vba]


    which did not work

  • Re: Vba Replace Funtion Wildcard Char


    RegExp is the tool for you here, check out http://www.regular-expressions.info. I'm just about to leave work, so don't have time to post more details. I'm sure someone else here can help.


    Edit: actually, you don't need grep here:

    Code
    s = "SELECT A, B, C, D, E FROM TABLE WHERE ID = '123123123';"
        s = "SELECT * " & Right$(s, Len(s) - InStr(1, s, " FROM"))
        Debug.Print s '--> SELECT * FROM TABLE WHERE ID = '123123123';
  • Re: Vba Replace Function Wildcard Char




    Those work and much simpliar to what I getting ready to do.


    Thanks

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!