|
In your trigger "Trigger1" the script line
set @id1=(select id from sal_t)
result in more than one row when you are inserting the second row to the "sal_t" table
So it result in the error "Subquery returnes more than 1 value.This is not permitted when the subquerry follows=,!=,<,..... or when the subquery is user as an expression."
Alter the trigger as follows,
alter TRIGGER Trigger1
ON dbo.sal_t
FOR INSERT
AS
begin
declare @id1 int
set @id1=(select top 1 id from sal_t)
insert into emp_t values(@id1,'ram')
end
It solves your problem. But the Trigger is not meaningfull. Can you please tell me the purpose of the trigger so that I can give you the response. Do you want to insert the last inserted id to emp_t table with the name as ram?
|