CREATE VIEW [dbo].[ApiImpLinesDocVeryficationView] as
  select l.Id, 'WeryfikacjaImp' Name ,126 DefId,2 Typ,l.ElementId ObiektId,    2 ObiektTyp, CAST(l.SN as varchar)+'|'+ CAST( l.SN2 as varchar) +'|' + CAST( NadrzId as varchar) +'|'  +  CAST(l.NadrzInfo as varchar)  +'|'  +  CAST(l.TS as varchar)   Wartosc   from dbo.ApiSerialNumbers l     where l.State=0
  UNION 
  select l.Id, 'MagazynOpis' Name,  126 DefId,2 Typ,l.ErpId ObiektId,    2 ObiektTyp, l.itemDescription  Wartosc from dbo.ApiLines l where itemDescription<>'' and  l.Status=0


GO
