-- ============================================= -- Author: -- Create date: <18.04.2008> -- Updated: <23.04.2010> -- Description: -- ============================================= CREATE VIEW [dbo].[vConsignor] AS SELECT -- Customer NULL AS CustomerNum_Customer, NULL AS Name1_Customer, NULL AS Name2_Customer, NULL AS StreetAddress1_Customer, NULL AS StreetAddress2_Customer, NULL AS StreetAddress3_Customer, NULL AS Postcode_Customer, NULL AS City_Customer, NULL AS Mobile_Customer, NULL AS Phone_Customer, NULL AS Email_Customer, NULL AS Fax_Customer, NULL AS PostOfficeBox_Customer, NULL AS PostOfficeBoxCity_Customer, NULL AS PostOfficeBoxPostcode_Customer, NULL AS CountryName_Customer, NULL AS CustomerOrigin_Customer, NULL AS Attention_Customer, NULL AS Contact_Customer, NULL AS ReceiverRef_Customer, NULL AS OurRef_Customer, NULL AS MessageToCarrier_Customer, NULL AS MessageToDriver_Customer, NULL AS MessageToReceiver_Customer, NULL AS PurchaseNo_Customer, NULL AS ShipmentTypeNo_Customer, -- Order CustomerOrder / CustomerOrderCopy Kundenr AS CustomerNum_Order, Ordrenr AS OrderNumber_Order, Kundenavn AS Name1_Order, NULL AS Name2_Order, Adresse AS StreetAddress1_Order, Adresse2 AS StreetAddress2_Order, NULL AS StreetAddress3_Order, Postnr AS Postcode_Order, Poststed AS City_Order, NULL AS Mobile_Order, NULL AS Phone_Order, NULL AS Email_Order, NULL AS Fax_Order, NULL AS PostOfficeBox_Order, NULL AS PostOfficeBoxCity_Order, NULL AS PostOfficeBoxPostcode_Order, Land AS CountryName_Order, NULL AS CustomerOrigin_Order, NULL AS Attention_Order, NULL AS Contact_Order, Deres_Ref AS ReceiverRef_Order, Vaar_Ref AS OurRef_Order, NULL AS MessageToCarrier_Order, NULL AS MessageToDriver_Order, NULL AS MessageToReceiver_Order, NULL AS PurchaseNo_Order, NULL AS ShipmentTypeNo_Order, -- Delivery NULL AS CustomerNum_Delivery, NULL AS Name1_Delivery, NULL AS Name2_Delivery, NULL AS StreetAddress1_Delivery, NULL AS StreetAddress2_Delivery, Levering AS StreetAddress3_Delivery, NULL AS Postcode_Delivery, NULL AS City_Delivery, NULL AS Mobile_Delivery, NULL AS Phone_Delivery, NULL AS Email_Delivery, NULL AS Fax_Delivery, NULL AS PostOfficeBox_Delivery, NULL AS PostOfficeBoxCity_Delivery, NULL AS PostOfficeBoxPostcode_Delivery, Landkode AS CountryName_Delivery, NULL AS CustomerOrigin_Delivery, NULL AS Attention_Delivery, NULL AS Contact_Delivery, NULL AS ReceiverRef_Delivery, NULL AS OurRef_Delivery, NULL AS MessageToCarrier_Delivery, NULL AS MessageToDriver_Delivery, NULL AS MessageToReceiver_Delivery, NULL AS PurchaseNo_Delivery, NULL AS ShipmentTypeNo_Delivery, -- Invoice NULL AS CustomerNum_Invoice, Kundenavn AS Name1_Invoice, NULL AS Name2_Invoice, Adresse AS StreetAddress1_Invoice, Adresse2 AS StreetAddress2_Invoice, NULL AS StreetAddress3_Invoice, Postnr AS Postcode_Invoice, Poststed AS City_Invoice, NULL AS Mobile_Invoice, NULL AS Phone_Invoice, NULL AS Email_Invoice, NULL AS Fax_Invoice, NULL AS PostOfficeBox_Invoice, NULL AS PostOfficeBoxCity_Invoice, NULL AS PostOfficeBoxPostcode_Invoice, NULL AS CountryName_Invoice, NULL AS CustomerOrigin_Invoice, NULL AS Attention_Invoice, NULL AS Contact_Invoice, NULL AS ReceiverRef_Invoice, NULL AS OurRef_Invoice, NULL AS MessageToCarrier_Invoice, NULL AS MessageToDriver_Invoice, NULL AS MessageToReceiver_Invoice, NULL AS PurchaseNo_Invoice, NULL AS ShipmentTypeNo_Invoice, -- Contact NULL AS ContactNum_Contact, NULL AS Name1_Contact, NULL AS Name2_Contact, NULL AS StreetAddress1_Contact, NULL AS StreetAddress2_Contact, NULL AS StreetAddress3_Contact, NULL AS Postcode_Contact, NULL AS City_Contact, mobil.Phone AS Mobile_Contact, telefon.Phone AS Phone_Contact, e.mailadr AS Email_Contact, fax.Phone AS Fax_Contact, NULL AS PostOfficeBox_Contact, NULL AS PostOfficeBoxCity_Contact, NULL AS PostOfficeBoxPostcode_Contact, NULL AS CountryName_Contact, NULL AS CustomerOrigin_Contact, NULL AS Attention_Contact, NULL AS Contact_Contact, NULL AS CustomerNum_Contact, -- Package NULL AS PackagesCount, NULL AS PackagesMarking, NULL AS PackagesContents, NULL AS PackagesWeight, NULL AS PackagesHeight, NULL AS PackagesLength, NULL AS PackagesWidth , NULL AS PackagesVolume, NULL AS CODAccount, NULL AS CODAmount, NULL AS CODKID, NULL AS CODReference, NULL AS InsuranceAmount, NULL AS InsuranceCategory, NULL AS InsurancePolicyNo, NULL AS DeliveryTerms, NULL AS Department, NULL AS InvoiceNumber, NULL AS PaymentTerms, NULL AS PaymentType, NULL AS ProjectName, NULL AS ProjectNumber, NULL AS CarrierCode, Ordrenr AS SearchKeyOrder1, NULL AS SearchKeyOrder2, NULL AS SearchKeyInvoiceNum, Kundenr AS SearchKeyCustomerNum, NULL AS SearchKeyContactNum, NULL AS Link_Table1, NULL AS Link_Table2, NULL AS Link_Table3, NULL AS Link_Table4, NULL AS Link_Table5, NULL AS Link_Table6, NULL AS Link_Table7, NULL AS Link_Table8, NULL AS Link_Table9, NULL AS Link_Table10 FROM dbo.ORDRE AS o INNER JOIN dbo.DEBITOR AS d ON o.Kundenr = d.Kontonr INNER JOIN dbo.c_Name AS n ON d.NameID = n.ID LEFT OUTER JOIN dbo.c_email AS e ON e.namelink = n.ID AND ISNULL(e.standard, 0) <> 0 LEFT OUTER JOIN dbo.c_Phone AS telefon ON telefon.NameLink = n.ID AND ISNULL(telefon.standard, 0) <> 0 AND telefon.phonetype = 150101 LEFT OUTER JOIN dbo.c_Phone AS mobil ON mobil.NameLink = n.ID AND ISNULL(mobil.standard, 0) <> 0 AND mobil.phonetype = 150102 LEFT OUTER JOIN dbo.c_Phone AS fax ON fax.NameLink = n.ID AND ISNULL(fax.standard, 0) <> 0 AND fax.phonetype = 150103 LEFT OUTER JOIN dbo.c_Contacts AS contact ON contact.FK_ID = d.Kontonr AND contact.FK_Type = 0 AND ISNULL(e.standard, 0) <> 0 GO