
/****** Object:  View [dbo].[ApiImpCustView]    Script Date: 13.09.2021 14:56:14 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO




CREATE VIEW [dbo].[ApiImpCustView] as

select c.Id, CustId, ''  Grupa, 
Code Kod, REPLACE(REPLACE(REPLACE(REPLACE(TAXID,' ',''),'-',''),'.',''),'/','') NIPE, c.Name Nazwa1, AdrrStreet Ulica, AdrrNumber NrDomu, AdrrAppNumber NrLokalu, AdrrZip KodPocztowy, AdrrCity Miasto, AdrrCountry KrajISO, Phone Telefon1, Phone2 Telefon2, Email Email,0 AkwizytorId, WWW, c.ErpId OptimaId, c.Id KntId, Notes, geolat, geolong,
SaveTS, ISNULL(d.ErpKey,'') Region
from dbo.ApiCustomers c 
LEFT OUTER JOIN dbo.ApiDictionaries d ON d.Id = c.RegionId

--where ISNULL(State,1) in (1,-1)
GO


