You can control this from business logic side of the application.
Or if you want to do from the Sqlserver trigger, you can avoid the insertion in table2 by adding the Where clause in the query of table2 insertion.
Add the where clause as follows
WHERE empID is not null .
Have a good Day
Can you post the code here? It seems you are not fetching the value if there is a null value which you need to change. By looking at your trigger we may be able to suggest you what change you need to make.
Asheej T K
table2 : sname(varchar(10)),age(int),bdate(datetime),address(varchar(50))
Update trigger ::
create trigger update_table on table1
declare @sname varchar(10)
declare @age varchar(10)
declare @bdate varchar(10)
declare @sql varchar(4000)
set @sname = (select sname from inserted)
set @age = (select age from inserted)
set @bdate = (select bdate from inserted)
set @sql = 'insert into table2(sname,age,bdate) values('+@sname+','+@age+','+@bdate+')'
Use the validation in your business logic or check where clause in your sql before insertion for null value.
CREATE TRIGGER EMP_SAL_CHECK ON Employee AFTER INSERT
DECLARE @sal INT
SELECT @sal=salary from inserted
raiserror('Salary less than 5000',16,1)
insert into Employee values('santhosh',3000,'A')
Kalandiyur Subramanian Mohan