Results 1 to 5 of 5
  1. #1
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067

    Weird Formatting in a view

    I have a SQL Server Table with a Varchar(10) Field. I've created a view to link to another table that has the same data (almost). The 1st table has Diagnosis Code Data such as 250.5 The second table from another source has Diagnosis Code data 2505. So I've created a view that has both formats so the 2 tables can be linked with the Replace(diags,'.','') as convdiag. Then in my query I link from table 1 to the intermediate view on diags and link to the 2nd table on convdiag to diagnosiscode. However I'm getting an error and when looking at the view the convdiag is formatted as varchar(8000) not (10) How do I fix that? I tried putting the ltrim and rtrim around the replace but apparently it still sets it up as a varchar(8000)????

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Shot in the dark, but what about wrapping the Replace() in a CAST() function?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    Actually found out I don't need to. the problem existed because I used that view as a linked table in Access and the link was failing due to the data type difference. But since all of the required tables for the query were in sql Server (different databases but still all SQL Server I just moved the query to SQL Server and made it a view. Problem solved the link works within SQL Server and I'm getting the data expected. Still validating just to be sure but so far I'm 20 out of 20.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it sorted out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Another alternative would have been to wrap the REPLACE() with a LEFT(,10) to force down the size.

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

Similar Threads

  1. Replies: 8
    Last Post: 04-29-2013, 11:23 AM
  2. Replies: 1
    Last Post: 04-24-2013, 08:51 PM
  3. Another Weird Problem
    By ksmith in forum Access
    Replies: 16
    Last Post: 07-24-2012, 10:45 AM
  4. Formatting a number field for datasheet view
    By RamiMohaisen in forum Access
    Replies: 3
    Last Post: 02-08-2012, 05:46 PM
  5. Weird Error
    By KevinMCB in forum Access
    Replies: 1
    Last Post: 02-16-2011, 02:23 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