SQL
USE [PrintMonitor]
GO
/****** Object:  UserDefinedFunction [dbo].[ReferenceDataItemExists]    Script Date: 10/15/2008 20:29:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/* --[ReferenceDataItemExists]------------------------------------------
 * Returns True if the reference data item exists (used in advanced
 * relational integrity rules)
 *
 */
CREATE FUNCTION [dbo].[ReferenceDataItemExists]
	(
	@DataItemName varchar(50),
	@DataItemValue varchar(50)
	)
RETURNS bit
AS
	BEGIN
	   DECLARE @Exists BIT
		IF EXISTS(SELECT 'A' FROM dbo.[Reference Data]
		          WHERE [Data Element Name] = @DataItemName
		            AND [Data Element Value] = @DataItemValue
		          )
			SELECT @Exists = -1
		ELSE
			SELECT @Exists = 0
			
	RETURN @Exists
	END

Last edited Oct 15, 2008 at 7:29 PM by Merrion, version 1

Comments

No comments yet.