
/****** Object:  StoredProcedure [getROImageByRODbID_FileName_DTS] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getROImageByRODbID_FileName_DTS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [getROImageByRODbID_FileName_DTS];
GO
	
CREATE PROCEDURE [dbo].[getROImageByRODbID_FileName_DTS]
(
	@RODbID int,
	@FileName nvarchar(255),
	@DTS datetime
)
AS
	SELECT
		[ImageID],
		[RODbID],
		[FileName],
		[Content],
		[Config],
		[DTS],
		[UserID],
		[LastChanged],
		(SELECT COUNT(*) FROM [Figures] WHERE [Figures].[ImageID]=[ROImages].[ImageID]) [FigureCount]
	FROM [ROImages]
	WHERE [RODbID]=@RODbID AND [FileName]=@FileName AND [DTS]=@DTS
	RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getROImageByRODbID_FileName_DTS Succeeded'
ELSE PRINT 'Procedure Creation: getROImageByRODbID_FileName_DTS Error on Creation'
GO
