1. USE [iXAlert_Main]
GO
/****** Object: UserDefinedFunction [dbo].[fnGetFrequencyName] Script Date:
07/22/2015 07:25:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Function to return the name of the Frequency setting for an alert
-- Created 2011.01.05 NBl
CREATE Function [dbo].[fnGetFrequencyName]
(
@AlertID int,
@CustomAlert bit
)
Returns varchar(60)
AS
BEGIN
Declare @FrequencyName varchar(60)
Declare @QueryID int
Declare @FrequencyID int
If @CustomAlert = 0
Begin
Set @QueryID = (Select ParamValue
from tbAlertParam where AlertID=@AlertID and ParamName = 'QueryID')
Set @FrequencyID = (Select FrequencyID from tbQuery where QueryID =
@QueryID)
Set @FrequencyName = (Select Frequency from tbFrequency where
FrequencyID = @FrequencyID)
End
Else If @CustomAlert = 1 -- use ty tables for custom alerts
Begin
Set @QueryID = (Select ParamValue
from tyAlertParam where AlertID=@AlertID and ParamName = 'QueryID')
Set @FrequencyID = (Select FrequencyID from tyQuery where QueryID =
@QueryID)
Set @FrequencyName = (Select Frequency from tbFrequency where
FrequencyID = @FrequencyID)
End
Return @FrequencyName
END
GO
EXEC sys.sp_addextendedproperty @name=N'Version', @value=N'7.1.09.01.37197' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'FUNCTION',@level1name=N'fnGetFrequencyName'
GO