
CREATE FUNCTION [dbo].[ApiObjectCourierPackages]
(
	@ObjectId int,
	@ObjectType int
)
RETURNS nvarchar(MAX)
AS
BEGIN


declare @Pozycje nvarchar(MAX)
set @Pozycje = ''

select  @Pozycje+=  d.Value+';'+d.Color +'|' from dbo.ApiCourierPackages cp 
JOIN dbo.ApiDictionaries d on d.ParentDefId=800 and d.NumberValue = cp.Status
JOIN dbo.ApiObjectRelations obr ON obr.RelObjectId = cp.Id and obr.RelObjectType = 800
and obr.ObjectId = @ObjectId and obr.ObjectType=@ObjectType;



return @Pozycje;

END


