Results 1 to 7 of 7
  1. #1
    JeffGeorge is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    111

    Field Data Truncation

    Is there a way to truncate existing data in a given field in a table? Specifically, I have a field in which I want to truncate that value for each record to the rightmost 7 characters. Is that possible without having to export, modify, import?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    You could build and execute an Update query

  3. #3
    JeffGeorge is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    111
    So, if I understand correctly, I can use the truncate function to update that field for all records within a query. I've never tried that, but I will. Thanks for the input.

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    I would create a new field and do the update to that new field. If you mess up you still have your original column. Once it looks good you can then delete the old one (or keep it) and rename the new one, etc.

    Look up Right Function.

  5. #5
    JeffGeorge is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    111
    I created a test database of one table with two fields of text type. I created an update query in Access that produced the following SQL:

    UPDATE Table1 SET Table1.Field2 = Right([Field1],7);

    This test produced the desired results. However, that raised two new questions:

    1) Can I substitute SET Table1.Field1 for SET Table1.Field2 and basically update the field in place?
    2) I've found out I have to do this in an MS SQL database. I duplicated my experiment in SQL Server Management studio with UPDATE Table1 SET Field2=RIGHT(Field1,7) but this turns Field2 into blank values. What am I missing?

  6. #6
    JeffGeorge is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    111
    Never mind that last question. Apparently I had a bunch of trailing spaces in my test field. That's why I was seeing nothing.

  7. #7
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    I believe you can update the same field with the new value. But again there is some risk to that such as what if your program crashes, loses connection to SQL in the middle of the update, etc. I always work about data getting lost. Maybe create a field called Field1_Original, do an update query first to move the values from Field1 to Field1_Original, then use 2nd Update query to change the value in Field1?

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

Similar Threads

  1. Unwanted Memo Field Truncation
    By stacerx2001 in forum Queries
    Replies: 4
    Last Post: 05-20-2015, 06:22 PM
  2. Replies: 1
    Last Post: 08-12-2013, 09:34 AM
  3. Excel Import field truncation problem (to Access Memo field)
    By jhrBanker in forum Import/Export Data
    Replies: 6
    Last Post: 07-27-2012, 08:52 AM
  4. Field Truncation
    By Jesse_Munos in forum Queries
    Replies: 1
    Last Post: 04-20-2012, 03:09 AM
  5. Piechart legend zero truncation
    By baba in forum Access
    Replies: 8
    Last Post: 11-29-2011, 09:49 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