
/****** Object:  View [dbo].[ApiImpCustPersonView]    Script Date: 13.09.2021 14:55:42 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[ApiImpCustPersonView] as
SELECT  p.[Id]
      ,[CustPersonId]
      ,c.ErpId [CustId]
      ,c.ErpId [CustCustId]
      ,[CustLocId]
      ,[CustLocLocId]
      ,p.[ErpId]
      ,p.[Name]
      ,[LastName]
      ,[Position]
      ,p.[Phone]
      ,p.[Phone2]
      ,p.[Email]
      ,p.[Notes]
      ,p.[VendorId]
      ,p.[TS]
      ,p.[SaveTS]
      ,p.[DeviceUid]
      ,p.[State]
      ,c.ErpId [CustErpId]
      ,[CustLocErpId]
  FROM [dbo].[ApiCustomerPersons] p
  JOIN dbo.ApiCustomers c 
  ON p.CustId = c.Id and c.ErpId<>0;
GO


