

CREATE FUNCTION [dbo].[ApiWmsStatusDoc]
(
	@ErpDocId int		
)
RETURNS  nvarchar(50)
BEGIN
   DECLARE @res nvarchar(50);
   set @res = ISNULL(
   (select dic.Value from dbo.ApiWmsDocuments doc JOIN dbo.ApiDictionaries dic ON doc.StateDoc = dic.Id and doc.ErpId = @ErpDocId) ,
   '');
   

	 return @res;
END


