I have this function but the if does'nt seem to be working correctly , I believe it's because of the comparison with null, I've had this problem before but gotten around it using the 2nd method which i'm not really fond of.
---------------method wanted
ALTER FUNCTION RETURN_BLOQUEO
(@prmMsisdsn VARCHAR(13),@prmServicio VARCHAR(13))
RETURNS int
AS
BEGIN
IF (SELECT MSISDN FROM dbo.View_Blacklist_Aplication
WHERE MSISDN=@prmMsisdsn AND SERVICIO=@prmServicio) = NULL
RETURN 0
RETURN 1
END
---------------------second method
ALTER FUNCTION RETORNAR_BLOQUEO (@prmMsisdsn VARCHAR(13),@prmServicio VARCHAR(13))
RETURNS int
AS
BEGIN
DECLARE @MSISDN VARCHAR(13)
set @MSISDN=(SELECT MSISDN FROM dbo.View_Blacklist_Aplication
WHERE MSISDN=@prmMsisdsn AND SERVICIO=@prmServicio)
IF ISNULL(@MSISDN,'NULL') = 'NULL'
RETURN 0
RETURN 1
END
---------------method wanted
ALTER FUNCTION RETURN_BLOQUEO
(@prmMsisdsn VARCHAR(13),@prmServicio VARCHAR(13))
RETURNS int
AS
BEGIN
IF (SELECT MSISDN FROM dbo.View_Blacklist_Aplication
WHERE MSISDN=@prmMsisdsn AND SERVICIO=@prmServicio) = NULL
RETURN 0
RETURN 1
END
---------------------second method
ALTER FUNCTION RETORNAR_BLOQUEO (@prmMsisdsn VARCHAR(13),@prmServicio VARCHAR(13))
RETURNS int
AS
BEGIN
DECLARE @MSISDN VARCHAR(13)
set @MSISDN=(SELECT MSISDN FROM dbo.View_Blacklist_Aplication
WHERE MSISDN=@prmMsisdsn AND SERVICIO=@prmServicio)
IF ISNULL(@MSISDN,'NULL') = 'NULL'
RETURN 0
RETURN 1
END