 ALTER VIEW [dbo].[qryrptCustomer]
AS
SELECT     Customer.FullName AS Customer, Customer_1.FullName AS Proxy, Customer.CompanyName, Customer.Salutation, Customer.FirstName, 
                      Customer.MiddleName, Customer.LastName, CustomerType.FullName AS CustomerType, Customer.IsActive, tblPriceLevel.Name AS PriceLevelName, 
                      tblPriceLevel.Rate AS PriceLevelRate, refPriceLevelType.PriceLevelTypeName AS PriceLevelType, Customer.CreditLimit, Customer.TotalBalance, 
                      Customer.OpenBalanceDate, ShipMethod.Name AS ShipMethod, ShipMethod.Price AS ShipMethodPrice, Term.Name AS Terms, 
                      refTermType.Name AS TermType, SalesRep.Initial AS Rep, SalesRep.Name AS RepName, FOB.FOB, SalesTaxCode.Name AS SalesTaxCode, 
                      SalesTaxCode.IsTaxable AS Taxable, refSalesTaxType.SalesTaxType, ItemSalesTax.Name AS ItemSalesTax, 
                      ItemSalesTax.TaxRate AS ItemSalesTaxRate, Customer.SalesTaxCertificate, Customer.AccountNumber, Customer.BillAddr1, Customer.BillAddr2, 
                      Customer.BillAddr3, Customer.BillAddr4, Customer.BillCity, Customer.BillState, Customer.BillZip, Customer.BillCountry, Customer.Contact, 
                      Customer.AltContact, Customer.Phone, Customer.AltPhone, Customer.Fax, Customer.Email, Customer.IsPrivate, tblAddresses.AddTitle, 
                      tblAddresses.AddAddr1, tblAddresses.AddAddr2, tblAddresses.AddAddr3, tblAddresses.AddAddr4, tblAddresses.AddCity, tblAddresses.AddState, 
                      tblAddresses.AddZip, tblAddresses.AddCountry, tblAddresses.AddContact, tblAddresses.AddAltContact, tblAddresses.AddPhone, 
                      tblAddresses.AddAltPhone, tblAddresses.AddFax, tblAddresses.AddEmail, Customer.CustomerCust1, Customer.CustomerCust2, 
                      Customer.CustomerCust3, Customer.CustomerCust5, Customer.CustomerCust4, Customer.CustomerCust6, Customer.CustomerCust7, 
                      Customer.CustomerCust8, Customer.CustomerCust9, Customer.CustomerCust10, Customer.TimeCreated, Customer.TimeModified, 
                      Customer.NCCustomerID, Class.FullName AS Class, Customer.IsLead, ItemDiscount.FullName AS Discount, case when Customer.IsCreditHold=0 then 'No' else 'Yes' end as OnHold 
FROM         refPriceLevelType with (nolock) INNER JOIN
                      tblPriceLevel with (nolock) ON refPriceLevelType.PriceLevelTypeID = tblPriceLevel.PriceLevelTypeID RIGHT OUTER JOIN
                      SalesRep with (nolock) RIGHT OUTER JOIN
                      Term with (nolock) RIGHT OUTER JOIN
                      tblAddresses with (nolock) RIGHT OUTER JOIN
                      Customer AS Customer_1 with (nolock) RIGHT OUTER JOIN
                      Customer with (nolock) LEFT OUTER JOIN
                      ItemDiscount with (nolock) ON Customer.DiscountRef = ItemDiscount.NCItemDiscountID ON Customer_1.NCCustomerID = Customer.Proxy ON 
                      tblAddresses.AddSourceID = Customer.NCCustomerID ON Term.NCTermID = Customer.TermsRef ON 
                      SalesRep.NCSalesRepID = Customer.SalesRepRef LEFT OUTER JOIN
                      CustomerType with (nolock) ON Customer.Type = CustomerType.NCCustomerTypeID LEFT OUTER JOIN
                      ItemSalesTax with (nolock) ON Customer.ItemSalesTaxRef = ItemSalesTax.NCItemSalesTaxID ON 
                      tblPriceLevel.PriceLevelID = Customer.PriceNameID LEFT OUTER JOIN
                      refSalesTaxType with (nolock) INNER JOIN
                      SalesTaxCode with (nolock) ON refSalesTaxType.SalesTaxTypeID = SalesTaxCode.SalesTaxTypeID ON 
                      Customer.SalesTaxCodeRef = SalesTaxCode.NCSalesTaxCodeID LEFT OUTER JOIN
                      FOB with (nolock) ON Customer.FOB = FOB.FOBID LEFT OUTER JOIN
                      ShipMethod with (nolock) ON Customer.ShipMethodRef = ShipMethod.NCShipMethodID LEFT OUTER JOIN
                      refTermType with (nolock) ON Term.TermType = refTermType.ID LEFT OUTER JOIN
                      Class with (nolock) ON Class.NCClassID = Customer.DftClassId
WHERE     (tblAddresses.AddDefault = 1)