My goal is to append or combine these records to have all 3 “TypeCode’s” on 1 record with 19 columns in a new Table as follows:
Part 1- (DX.LoanNo, DX.FundDate, BR.BorrLastName, BR.BorrFirstName, BR.BorrMiddleName, BR.BorrSSN, BR.BorrTypeCode, DX.Address, DX.LienCode) = (TypeCode 1)
Part 2 – (BR.BorrLastName, BR.BorrFirstName, BR.BorrMiddleName, BR.BorrSSN, BR.BorrTypeCode) = (TypeCode 2)
Part 3 – (BR.BorrLastName, BR.BorrFirstName, BR.BorrMiddleName, BR.BorrSSN, BR.BorrTypeCode) = (TypeCode 3)
*NOTE: There is a “LienCode” in each Table (1st lien =1 and 2nd lien = 2). I would then have 2 new Tables representing Table.Lien 1 and Table.Lien 2. I eventually want to send these new Tables into Access via Excel as to not lose any data due to the Varchar 255 format in SQL. This is the way the DB came.
Current Tables (all are Varchar 255 nulls allowed):
Table 1=DX
DX.LoanNo - (no leading zeros or alphas)
DX.FullName - (text only with commas separating last, first and middle names)
DX.SSN - (some records have dashes and some don’t)
DX.TypeCode - (single digit from 1-3)
DX.FundDate - (date)
DX.Address - (alphanumeric)
DX.LienCode - (single digit from 1-2)
Table 2=BR (all are Varchar 255 nulls allowed)
BR.BorrLoanNo - (no leading zeros or alphas)- (same info as DX.LoanNo)
BR.BorrLastName - (text)
BR.BorrFirstName - (text)
BR.BorrMiddleName - (text)
BR.BorrSSN - (same as above) – (some fields are missing data or vice-versa with DX.SSN)
BR.BorrTypeCode - (single digit from 1-3) – (Same info as DX.TypeCode)
Current Script:
Expand|Select|Wrap|Line Numbers
- SELECT DX.LoanNo, DX.FundDate, BR.BorrLastName, BR.BorrFirstName,
- BR.BorrMiddleName, BR.BorrSSN, BR.BorrTypeCode, DX.Address, DX.LienCode
- FROM dbo.DX LEFT OUTER JOIN
- dbo.BR ON dbo.DX.LoanNo = dbo.BR.BorrLoanNo
- WHERE (dbo.BR.BorrTypeCode = '1') AND (dbo.DX.Lien = '1')
- ORDER BY dbo.DX.LoanNo
Blue