Showing posts with label Trigger After Insert. Show all posts
Showing posts with label Trigger After Insert. Show all posts

Sunday, August 3, 2014

Trigger After Insert



alter TRIGGER AFTER INSERT ON asdf
AFTER INSERT
as
BEGIN
DECLARE @EMPID VARCHAR(50)
DECLARE @ENAME VARCHAR(50)
DECLARE @SALARY VARCHAR(50)


SELECT @EMPID= i.empid FROM inserted i
select @ENAME=i.ename from inserted i
select @SALARY=i.Salary from inserted i


DECLARE @SUBSTRING VARCHAR(50)=SUBSTRING(@EMPID,1,1)+'_'+SUBSTRING(@ENAME,1,1)+'_'+
SUBSTRING(cast(@SALARY asvarchar(50)),1,2)


update asdf set associatID=@SUBSTRING where empid=@EMPID


END
GO