I have following tables:
tbl_workshop
id int identity
Name nvarchar(10)
Address nvarchar(40)
tbl_workshop_temp
id int identity
code int
InsUpkey smallint
And I have follwing statements
insert into tbl_workshop
(Name,Address)
values('x','y')
select @@identity -- My problem is here
And I have following trigger for insert too:
create trigger InsertedWorkshop
on tbl_workshop
for insert
as
insert into tbl_workshop_temp
(code,InsUpKey)
select id,1
from inserted
when the select @@identity
statement runs I get the id
of inserted row in tbl_workshop_temp
instead of id
inserted in tbl_workshop
I know I must use scope_identity
but I can't change the code. I just can change my trigger.
What should I do now? Please help me.