July 29, 2004 at 6:58 am
Write a trigger for checking duplicate email id whenever a new record is being inserted into table.However email column be null,but if is not null then no new email id is matched with previous emailid in the table
July 29, 2004 at 8:17 am
could be something like this :
CREATE TRIGGER TrIU_T_Mytable ON dbo.Mytable
FOR INSERT, UPDATE
AS
IF MyEmailColumn is NOT null
begin
-- must be unique where not null
If exists (select * from dbo.Mytable T inner join inserted Ins where T.MyEmailColumn = Ins.MyEmailColumn) begin
raiserror("Duplicate Emailaddress", 12,1)
rollback transaction
end
end
GO
test it test it test it
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply