

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

SET QUOTED_IDENTIFIER ON
GO


CREATE VIEW [dbo].[ApiStockView2] as
select TwZ_TwZId BatchId, TrE_TrEID LineId, 1 FlowDirection, TwZ_TwrId ItemId, TwZ_MagId MagId, TwZ_Data Date,
nag.TrN_NumerPelny Batch, TrS_TrSIdDost SourceBatchId, '' LocationName,
'' Description, TwZ_Cena Price, TwZ_Ilosc Stock, TwZ_Ilosc OrgStock, 0 as Type
 from CDN.TwrZasoby z 
 JOIN CDN.TraSElem sel ON sel.TrS_TrSID = TwZ_TrSIdDost
 JOIN CDN.TraElem el ON el.TrE_TrEID = sel.TrS_TrEId
 JOIN CDN.TraNag nag ON nag.TrN_TrNID = el. TrE_TrNId
 

GO


