
CREATE FUNCTION [dbo].[ApiRoofOrderWmsStatus]
(
	@OrderId int
)
RETURNS nvarchar(MAX)
AS
BEGIN


declare @Pozycje nvarchar(MAX)
select  @Pozycje+= NumberString+'['+ ISNULL(dict.Value,'') +']' +'|' 
from dbo.ApiWmsDocuments doc 
LEFT OUTER JOIN  dbo.ApiDictionaries dict on doc.StateDoc =dict.Id
where ObjectId = @OrderId and ObjectType = 10 and StateId=0;
--select @Pozycje+= p.ItemName  + '['+cast(p.OrgQuantity as varchar) +' '+ p.UM +']'+'|' from dbo.ApiWmsDocLines p  where DocumentId=@WmsDocId

return @Pozycje;

END



