USE [DD_ECM]
GO

/****** Object:  View [dbo].[VWCUST_NAVISION_VENDORACCOUNTS]    Script Date: 21.03.2024 17:01:54 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



-- 14.07.2023 MS Update BC ID
-- 10.01.2022 Ergänzung IBAN per join
-- 23.09.2021 Order by eingebaut
-- 22.09.2021 "Stadtentwicklung Bebra GmbH" entfernt, da seit 2016 inaktiv
-- 20.09.2021 initial

CREATE view [dbo].[VWCUST_NAVISION_VENDORACCOUNTS] 
as

SELECT TOP 1000000
	  'SB-Abwasserbetrieb' as 'Mandant'
      ,[V].[No_] as 'LieferantenNr'
      ,[V].[Name]
	  ,[VBA].[IBAN] as 'Pay-to IBAN'
      ,[V].[Search Name]
      ,[V].[Name 2]
      ,[V].[Address]
      ,[V].[Address 2]
      ,[V].[City]
      ,[V].[Contact]
      ,[V].[Phone No_]
      ,[V].[Telex No_]
      ,[V].[Our Account No_]
      ,[V].[Territory Code]
      ,[V].[Global Dimension 1 Code]
      ,[V].[Global Dimension 2 Code]
      ,[V].[Budgeted Amount]
      ,[V].[Vendor Posting Group]
      ,[V].[Currency Code]
      ,[V].[Language Code]
      ,[V].[Statistics Group]
      ,[V].[Payment Terms Code]
      ,[V].[Fin_ Charge Terms Code]
      ,[V].[Purchaser Code]
      ,[V].[Shipment Method Code]
      ,[V].[Shipping Agent Code]
      ,[V].[Invoice Disc_ Code]
      ,[V].[Country_Region Code]
      ,[V].[Blocked]
      ,[V].[Pay-to Vendor No_]
      ,[V].[Priority]
      ,[V].[Payment Method Code]
      ,[V].[Last Date Modified]
      ,[V].[Application Method]
      ,[V].[Prices Including VAT]
      ,[V].[Fax No_]
      ,[V].[Telex Answer Back]
      ,[V].[VAT Registration No_]
      ,[V].[Gen_ Bus_ Posting Group]
      ,[V].[GLN]
      ,[V].[Post Code]
      ,[V].[County]
      ,[V].[E-Mail]
      ,[V].[Home Page]
      ,[V].[No_ Series]
      ,[V].[Tax Area Code]
      ,[V].[Tax Liable]
      ,[V].[VAT Bus_ Posting Group]
      ,[V].[Block Payment Tolerance]
      ,[V].[IC Partner Code]
      ,[V].[Prepayment _]
      ,[V].[Partner Type]
      ,[V].[Privacy Blocked]
      ,[V].[Creditor No_]
      ,[V].[Preferred Bank Account Code]
      ,[V].[Cash Flow Payment Terms Code]
      ,[V].[Primary Contact No_]
      ,[V].[Responsibility Center]
      ,[V].[Location Code]
      ,[V].[Lead Time Calculation]
      ,[V].[Base Calendar Code]
      ,[V].[Registration No_]
      ,[V].[OU]
      ,[V].[OU Code]
      ,[V].[No_ Entries for Avis]
      ,[V].[Direction Code]
      ,[V].[Payment Type]
      ,[V].[Delivery Reminder Terms]
      ,[V].[VU Person No_]
      ,[V].[Pers_ Salutation]
      ,[V].[Title]
      ,[V].[First Name]
      ,[V].[Lowest Order Value]
      ,[V].[Industry Group]
      ,[V].[Quality Mgt_]
      ,[V].[QM Certificate valid till]
      ,[V].[Work Safety Mgt_]
      ,[V].[WS Certificate valid till]
      ,[V].[Ecology Mgt_]
      ,[V].[EC Certificate valid till]
      ,[V].[Energy Mgt_]
      ,[V].[EN Certificate valid till]
      ,[V].[Outside Company Training]
      ,[V].[OC Training valid till]
      ,[V].[Secrecy Aggreement]
      ,[V].[SE Aggreement valid till]
      ,[V].[Payment Terms Code (IR)]
      ,[V].[Exemption answer]
      ,[V].[Exemption answer valid to]
      ,[V].[Exemption answer re-submission]
      ,[V].[Responsibly Tax office]
      ,[V].[Reference to exemption answer]
      ,[V].[Days before expiration E_ a_]
      ,[V].[Safety No_]
      ,[V].[Concern Elimination]
      ,[V].[Elimination ShortcutDimCode]
      ,[V].[Customizing WO]
      ,[V].[Customizing WO valid till]
      ,[V].[Last Modified Date Time]
      ,[V].[Disable Search by Name]
      ,[V].[Document Sending Profile]
      ,[V].[Validate EU Vat Reg_ No_]
      ,[V].[Id]
      ,[V].[Currency Id]
      ,[V].[Payment Terms Id]
      ,[V].[Payment Method Id]
      ,[V].[Information Security]
      ,[V].[Information Security valid to]
      ,[V].[Security Clause]
      ,[V].[Security Clause valid to]
      ,[V].[ISMS]
      ,[V].[ISMS valid to]
	FROM		[NTSERP\NTSSUITE].[NTSsuite2015].[dbo].[Abwasserbetrieb d_ Stadt Bebra$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972]				as [V]
	LEFT JOIN	[NTSERP\NTSSUITE].[NTSsuite2015].[dbo].[Abwasserbetrieb d_ Stadt Bebra$Vendor Bank Account$437dbf0e-84ff-417a-965d-ed2bb9650972]		as [VBA] (NOLOCK) ON [V].[No_] = [VBA].[Vendor No_]
	WHERE LEN([V].[Name]) > 1

  UNION ------------------------------------------------------------------------------------

SELECT TOP 1000000
       'SB-Bäderbetrieb' as 'Mandant'
      ,[V].[No_] as 'LieferantenNr'
      ,[V].[Name]
	  ,[VBA].[IBAN] as 'Pay-to IBAN'
      ,[V].[Search Name]
      ,[V].[Name 2]
      ,[V].[Address]
      ,[V].[Address 2]
      ,[V].[City]
      ,[V].[Contact]
      ,[V].[Phone No_]
      ,[V].[Telex No_]
      ,[V].[Our Account No_]
      ,[V].[Territory Code]
      ,[V].[Global Dimension 1 Code]
      ,[V].[Global Dimension 2 Code]
      ,[V].[Budgeted Amount]
      ,[V].[Vendor Posting Group]
      ,[V].[Currency Code]
      ,[V].[Language Code]
      ,[V].[Statistics Group]
      ,[V].[Payment Terms Code]
      ,[V].[Fin_ Charge Terms Code]
      ,[V].[Purchaser Code]
      ,[V].[Shipment Method Code]
      ,[V].[Shipping Agent Code]
      ,[V].[Invoice Disc_ Code]
      ,[V].[Country_Region Code]
      ,[V].[Blocked]
      ,[V].[Pay-to Vendor No_]
      ,[V].[Priority]
      ,[V].[Payment Method Code]
      ,[V].[Last Date Modified]
      ,[V].[Application Method]
      ,[V].[Prices Including VAT]
      ,[V].[Fax No_]
      ,[V].[Telex Answer Back]
      ,[V].[VAT Registration No_]
      ,[V].[Gen_ Bus_ Posting Group]
      ,[V].[GLN]
      ,[V].[Post Code]
      ,[V].[County]
      ,[V].[E-Mail]
      ,[V].[Home Page]
      ,[V].[No_ Series]
      ,[V].[Tax Area Code]
      ,[V].[Tax Liable]
      ,[V].[VAT Bus_ Posting Group]
      ,[V].[Block Payment Tolerance]
      ,[V].[IC Partner Code]
      ,[V].[Prepayment _]
      ,[V].[Partner Type]
      ,[V].[Privacy Blocked]
      ,[V].[Creditor No_]
      ,[V].[Preferred Bank Account Code]
      ,[V].[Cash Flow Payment Terms Code]
      ,[V].[Primary Contact No_]
      ,[V].[Responsibility Center]
      ,[V].[Location Code]
      ,[V].[Lead Time Calculation]
      ,[V].[Base Calendar Code]
      ,[V].[Registration No_]
      ,[V].[OU]
      ,[V].[OU Code]
      ,[V].[No_ Entries for Avis]
      ,[V].[Direction Code]
      ,[V].[Payment Type]
      ,[V].[Delivery Reminder Terms]
      ,[V].[VU Person No_]
      ,[V].[Pers_ Salutation]
      ,[V].[Title]
      ,[V].[First Name]
      ,[V].[Lowest Order Value]
      ,[V].[Industry Group]
      ,[V].[Quality Mgt_]
      ,[V].[QM Certificate valid till]
      ,[V].[Work Safety Mgt_]
      ,[V].[WS Certificate valid till]
      ,[V].[Ecology Mgt_]
      ,[V].[EC Certificate valid till]
      ,[V].[Energy Mgt_]
      ,[V].[EN Certificate valid till]
      ,[V].[Outside Company Training]
      ,[V].[OC Training valid till]
      ,[V].[Secrecy Aggreement]
      ,[V].[SE Aggreement valid till]
      ,[V].[Payment Terms Code (IR)]
      ,[V].[Exemption answer]
      ,[V].[Exemption answer valid to]
      ,[V].[Exemption answer re-submission]
      ,[V].[Responsibly Tax office]
      ,[V].[Reference to exemption answer]
      ,[V].[Days before expiration E_ a_]
      ,[V].[Safety No_]
      ,[V].[Concern Elimination]
      ,[V].[Elimination ShortcutDimCode]
      ,[V].[Customizing WO]
      ,[V].[Customizing WO valid till]
      ,[V].[Last Modified Date Time]
      ,[V].[Disable Search by Name]
      ,[V].[Document Sending Profile]
      ,[V].[Validate EU Vat Reg_ No_]
      ,[V].[Id]
      ,[V].[Currency Id]
      ,[V].[Payment Terms Id]
      ,[V].[Payment Method Id]
      ,[V].[Information Security]
      ,[V].[Information Security valid to]
      ,[V].[Security Clause]
      ,[V].[Security Clause valid to]
      ,[V].[ISMS]
      ,[V].[ISMS valid to]
  FROM		[NTSERP\NTSSUITE].[NTSsuite2015].[dbo].[Bäderbetrieb der Stadt Bebra$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972]					as [V]
  LEFT JOIN	[NTSERP\NTSSUITE].[NTSsuite2015].[dbo].[Bäderbetrieb der Stadt Bebra$Vendor Bank Account$437dbf0e-84ff-417a-965d-ed2bb9650972]	as [VBA] (NOLOCK) ON [V].[No_] = [VBA].[Vendor No_]
  WHERE LEN([V].[Name]) > 1

  UNION ------------------------------------------------------------------------------------

SELECT TOP 1000000
       'SWB-Netz' as 'Mandant'
      ,[V].[No_] as 'LieferantenNr'
      ,[V].[Name]
	  ,[VBA].[IBAN] as 'Pay-to IBAN'
      ,[V].[Search Name]
      ,[V].[Name 2]
      ,[V].[Address]
      ,[V].[Address 2]
      ,[V].[City]
      ,[V].[Contact]
      ,[V].[Phone No_]
      ,[V].[Telex No_]
      ,[V].[Our Account No_]
      ,[V].[Territory Code]
      ,[V].[Global Dimension 1 Code]
      ,[V].[Global Dimension 2 Code]
      ,[V].[Budgeted Amount]
      ,[V].[Vendor Posting Group]
      ,[V].[Currency Code]
      ,[V].[Language Code]
      ,[V].[Statistics Group]
      ,[V].[Payment Terms Code]
      ,[V].[Fin_ Charge Terms Code]
      ,[V].[Purchaser Code]
      ,[V].[Shipment Method Code]
      ,[V].[Shipping Agent Code]
      ,[V].[Invoice Disc_ Code]
      ,[V].[Country_Region Code]
      ,[V].[Blocked]
      ,[V].[Pay-to Vendor No_]
      ,[V].[Priority]
      ,[V].[Payment Method Code]
      ,[V].[Last Date Modified]
      ,[V].[Application Method]
      ,[V].[Prices Including VAT]
      ,[V].[Fax No_]
      ,[V].[Telex Answer Back]
      ,[V].[VAT Registration No_]
      ,[V].[Gen_ Bus_ Posting Group]
      ,[V].[GLN]
      ,[V].[Post Code]
      ,[V].[County]
      ,[V].[E-Mail]
      ,[V].[Home Page]
      ,[V].[No_ Series]
      ,[V].[Tax Area Code]
      ,[V].[Tax Liable]
      ,[V].[VAT Bus_ Posting Group]
      ,[V].[Block Payment Tolerance]
      ,[V].[IC Partner Code]
      ,[V].[Prepayment _]
      ,[V].[Partner Type]
      ,[V].[Privacy Blocked]
      ,[V].[Creditor No_]
      ,[V].[Preferred Bank Account Code]
      ,[V].[Cash Flow Payment Terms Code]
      ,[V].[Primary Contact No_]
      ,[V].[Responsibility Center]
      ,[V].[Location Code]
      ,[V].[Lead Time Calculation]
      ,[V].[Base Calendar Code]
      ,[V].[Registration No_]
      ,[V].[OU]
      ,[V].[OU Code]
      ,[V].[No_ Entries for Avis]
      ,[V].[Direction Code]
      ,[V].[Payment Type]
      ,[V].[Delivery Reminder Terms]
      ,[V].[VU Person No_]
      ,[V].[Pers_ Salutation]
      ,[V].[Title]
      ,[V].[First Name]
      ,[V].[Lowest Order Value]
      ,[V].[Industry Group]
      ,[V].[Quality Mgt_]
      ,[V].[QM Certificate valid till]
      ,[V].[Work Safety Mgt_]
      ,[V].[WS Certificate valid till]
      ,[V].[Ecology Mgt_]
      ,[V].[EC Certificate valid till]
      ,[V].[Energy Mgt_]
      ,[V].[EN Certificate valid till]
      ,[V].[Outside Company Training]
      ,[V].[OC Training valid till]
      ,[V].[Secrecy Aggreement]
      ,[V].[SE Aggreement valid till]
      ,[V].[Payment Terms Code (IR)]
      ,[V].[Exemption answer]
      ,[V].[Exemption answer valid to]
      ,[V].[Exemption answer re-submission]
      ,[V].[Responsibly Tax office]
      ,[V].[Reference to exemption answer]
      ,[V].[Days before expiration E_ a_]
      ,[V].[Safety No_]
      ,[V].[Concern Elimination]
      ,[V].[Elimination ShortcutDimCode]
      ,[V].[Customizing WO]
      ,[V].[Customizing WO valid till]
      ,[V].[Last Modified Date Time]
      ,[V].[Disable Search by Name]
      ,[V].[Document Sending Profile]
      ,[V].[Validate EU Vat Reg_ No_]
      ,[V].[Id]
      ,[V].[Currency Id]
      ,[V].[Payment Terms Id]
      ,[V].[Payment Method Id]
      ,[V].[Information Security]
      ,[V].[Information Security valid to]
      ,[V].[Security Clause]
      ,[V].[Security Clause valid to]
      ,[V].[ISMS]
      ,[V].[ISMS valid to]
  FROM		[NTSERP\NTSSUITE].[NTSsuite2015].[dbo].[STW Bebra GmbH inkl Netz$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972]				as [V]
  LEFT JOIN	[NTSERP\NTSSUITE].[NTSsuite2015].[dbo].[STW Bebra GmbH inkl Netz$Vendor Bank Account$437dbf0e-84ff-417a-965d-ed2bb9650972]	as [VBA] (NOLOCK) ON [V].[No_] = [VBA].[Vendor No_]
  WHERE LEN([V].[Name]) > 1

  UNION ------------------------------------------------------------------------------------

SELECT TOP 1000000
       'SWB-Vertrieb' as 'Mandant'
      ,[V].[No_] as 'LieferantenNr'
      ,[V].[Name]
	  ,[VBA].[IBAN] as 'Pay-to IBAN'
      ,[V].[Search Name]
      ,[V].[Name 2]
      ,[V].[Address]
      ,[V].[Address 2]
      ,[V].[City]
      ,[V].[Contact]
      ,[V].[Phone No_]
      ,[V].[Telex No_]
      ,[V].[Our Account No_]
      ,[V].[Territory Code]
      ,[V].[Global Dimension 1 Code]
      ,[V].[Global Dimension 2 Code]
      ,[V].[Budgeted Amount]
      ,[V].[Vendor Posting Group]
      ,[V].[Currency Code]
      ,[V].[Language Code]
      ,[V].[Statistics Group]
      ,[V].[Payment Terms Code]
      ,[V].[Fin_ Charge Terms Code]
      ,[V].[Purchaser Code]
      ,[V].[Shipment Method Code]
      ,[V].[Shipping Agent Code]
      ,[V].[Invoice Disc_ Code]
      ,[V].[Country_Region Code]
      ,[V].[Blocked]
      ,[V].[Pay-to Vendor No_]
      ,[V].[Priority]
      ,[V].[Payment Method Code]
      ,[V].[Last Date Modified]
      ,[V].[Application Method]
      ,[V].[Prices Including VAT]
      ,[V].[Fax No_]
      ,[V].[Telex Answer Back]
      ,[V].[VAT Registration No_]
      ,[V].[Gen_ Bus_ Posting Group]
      ,[V].[GLN]
      ,[V].[Post Code]
      ,[V].[County]
      ,[V].[E-Mail]
      ,[V].[Home Page]
      ,[V].[No_ Series]
      ,[V].[Tax Area Code]
      ,[V].[Tax Liable]
      ,[V].[VAT Bus_ Posting Group]
      ,[V].[Block Payment Tolerance]
      ,[V].[IC Partner Code]
      ,[V].[Prepayment _]
      ,[V].[Partner Type]
      ,[V].[Privacy Blocked]
      ,[V].[Creditor No_]
      ,[V].[Preferred Bank Account Code]
      ,[V].[Cash Flow Payment Terms Code]
      ,[V].[Primary Contact No_]
      ,[V].[Responsibility Center]
      ,[V].[Location Code]
      ,[V].[Lead Time Calculation]
      ,[V].[Base Calendar Code]
      ,[V].[Registration No_]
      ,[V].[OU]
      ,[V].[OU Code]
      ,[V].[No_ Entries for Avis]
      ,[V].[Direction Code]
      ,[V].[Payment Type]
      ,[V].[Delivery Reminder Terms]
      ,[V].[VU Person No_]
      ,[V].[Pers_ Salutation]
      ,[V].[Title]
      ,[V].[First Name]
      ,[V].[Lowest Order Value]
      ,[V].[Industry Group]
      ,[V].[Quality Mgt_]
      ,[V].[QM Certificate valid till]
      ,[V].[Work Safety Mgt_]
      ,[V].[WS Certificate valid till]
      ,[V].[Ecology Mgt_]
      ,[V].[EC Certificate valid till]
      ,[V].[Energy Mgt_]
      ,[V].[EN Certificate valid till]
      ,[V].[Outside Company Training]
      ,[V].[OC Training valid till]
      ,[V].[Secrecy Aggreement]
      ,[V].[SE Aggreement valid till]
      ,[V].[Payment Terms Code (IR)]
      ,[V].[Exemption answer]
      ,[V].[Exemption answer valid to]
      ,[V].[Exemption answer re-submission]
      ,[V].[Responsibly Tax office]
      ,[V].[Reference to exemption answer]
      ,[V].[Days before expiration E_ a_]
      ,[V].[Safety No_]
      ,[V].[Concern Elimination]
      ,[V].[Elimination ShortcutDimCode]
      ,[V].[Customizing WO]
      ,[V].[Customizing WO valid till]
      ,[V].[Last Modified Date Time]
      ,[V].[Disable Search by Name]
      ,[V].[Document Sending Profile]
      ,[V].[Validate EU Vat Reg_ No_]
      ,[V].[Id]
      ,[V].[Currency Id]
      ,[V].[Payment Terms Id]
      ,[V].[Payment Method Id]
      ,[V].[Information Security]
      ,[V].[Information Security valid to]
      ,[V].[Security Clause]
      ,[V].[Security Clause valid to]
      ,[V].[ISMS]
      ,[V].[ISMS valid to]
  FROM		[NTSERP\NTSSUITE].[NTSsuite2015].[dbo].[Vertrieb STW Bebra$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972]				as [V]
  LEFT JOIN	[NTSERP\NTSSUITE].[NTSsuite2015].[dbo].[Vertrieb STW Bebra$Vendor Bank Account$437dbf0e-84ff-417a-965d-ed2bb9650972]	as [VBA] (NOLOCK) ON [V].[No_] = [VBA].[Vendor No_]
  WHERE LEN([V].[Name]) > 1

ORDER BY Mandant, No_ ASC




GO


