I am writing a trigger in SQL Server like this
DECLARE @N_CATComp smallint, @EXON varchar(69), @DATEDEB varchar(15), @DATEFIN varchar(15)
SELECT
@N_CATComp = N_CATCompta,
@EXON =[Exon N°],
@DATEDEB = CONVERT(varchar(15), [Date début] , 103),
@DATEDEB = CONVERT(varchar(15), [Date début] , 103)
FROM INSERTED
IF (@N_CATComp =4) AND ( ISNULL(@EXON,'')='' OR ISNULL(@DATEDEB,'') ='' OR ISNULL(@DATEFIN,'') ='')
BEGIN
RAISERROR('false',11,1)
END
MY problem is that when @exon, @datedeb,@datefin are not null and catcomp=4 the raiserror appears which it shouldn't i tried to elpace isnull by for example len(@EXON)=0 in this case ven if the values are null then the raiserror don't appears
Here is the same thing with all those scalar variables removed.
IF EXISTS
(
SELECT *
from inserted
where N_CATCompta = 4
AND
(
ISNULL([Exon N°], '') = ''
OR
ISNULL([Date début], '') = ''
)
)
RAISERROR('false',11,1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.