CREATE TRIGGER before_insert_user
ON users
INSTEAD OF INSERT
AS
BEGIN
SET NOCOUNT ON;
if exists (Select * from inserted i inner join users t
on t.user_login_id=i.user_login_id and t.member_id=i.member_id)
raiserror('Duplicated user login name',16,1)
else
insert users
select user_login_id, user_full_name, member_id, HASHBYTES('MD5',password_temp), ''
from inserted
END
GO
|