

/****** Object:  StoredProcedure [dbo].[ApiGetUploads]    Script Date: 07.09.2021 13:50:36 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



CREATE PROCEDURE [dbo].[ApiGetUploads]	
@ObjectType int,
@ObjectId int
AS 
BEGIN

select * from dbo.ApiUploadeds where ObjectId = @ObjectId and ObjectType=@ObjectType and OrginalId=0 and Status>=0
UNION
select u1.* from dbo.ApiUploadeds u1 JOIN dbo.ApiUploadeds u2 ON u2.ObjectId = @ObjectId and u2.ObjectType=@ObjectType and u2.OrginalId=u1.ID and  u1.Status>=0
END
  
GO


