Results 1 to 6 of 6
  1. #1
    samdahlr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    28

    Query to edit an entire column of values at once

    Hello,



    I have a column of data that are contact ID's. They are in this format "ESP-CON-123456". I want to get rid of the "ESP-CON-" portion for the entire column and have each ID in the format of "123456". Anyone have a query for this preferably in SQL?

    Thank you!

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Are the IDs always exactly 14 characters long and you want to get rid of exactly the first 8 characters?

  3. #3
    samdahlr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    28
    No some of them are 12 characters, and just a few of them do not have that exact format, but almost all of them do.

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    We need to know of all the possible formulations so we know how to write the formula to do what you want.
    Can you list the other possible layouts?
    For example, the IDs that are 12 characters, how many characters do you want to lose/keep on those?

    Basically, we need to come up with a complete set of rules to handle each possible scenario in order to program something to do what you want.

  5. #5
    samdahlr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    28
    I found out the other formats were a typo in the database, so I will delete those separately. Here are the only two formats:

    ESPE-CON-123456

    ESPE-CON-12345

    (I forgot the last E on ESPE in my original post. The first 9 characters are always "ESPE-CON-", and I only want the remaining characters.)

    Thank you

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    In Access, the SQL code would look something like this:
    Code:
    UPDATE TableName
    SET TableName.ContractID = Mid(TableName.ContractID,10,6);
    In native SQL, you would substitute the MID function with SUBSTRING (that is SQL's equivalent of the Access MID function).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Drop Down Box changes entire column
    By tennisbuck in forum Forms
    Replies: 4
    Last Post: 02-26-2014, 12:23 PM
  2. Replies: 5
    Last Post: 07-09-2013, 11:16 AM
  3. added text to entire column in the Query
    By Jerseynjphillypa in forum Queries
    Replies: 3
    Last Post: 06-12-2012, 09:39 AM
  4. Replies: 3
    Last Post: 04-01-2012, 01:11 PM
  5. Replies: 4
    Last Post: 01-02-2012, 11:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums