Results 1 to 2 of 2

Thread: SQL Server 2005 JOINing Slightly Different Tables

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2003
    Location
    Chicago, IL
    Posts
    102

    SQL Server 2005 JOINing Slightly Different Tables

    We have two tables, TableA and TableB that we wish to join on a common column. The only problem is that the data in that column varies slightly. In TableA it will be in the format UNIT_X while in TableB it will be in the format UNIT_X_B. There can be NULLS in the columns, but all other data will meet this format. There are a slew of other columns involved in the two tables, including some linked columns, but these are the ones that matter. When we tried creating another column in TableB that was the desired column SUBSTRING'ed down, SQL starts timing out, not due to too many returned rows but some other issue we can't nail down. Remove the reference to the new row and it works fine.

    Any suggestions for JOINing these two tables?

    Thanks in advance.
    Joe Cody
    Data Integration Engineer
    Novaspect, Inc.
    Elk Grove Village, IL

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: SQL Server 2005 JOINing Slightly Different Tables

    By TableA "in the format" do you mean the field format is always 4 characters, an underscore and 1 character? If yes,

    Select Fields
    From TableA Inner Join TableB On TableA.Field = Substring(TableB.Field,1,6)

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