Reputation: 2832
I have heard that the 'inserted' table automatically stores the last inserted record of any table temporarily.I was able to get the values from this inserted table when using triggers but not manually as
insert into samantha (id , name) values (11,'has')
select *from inserted
I am getting the error message as
Invalid object name 'inserted'.
Can you please give the reason.Thanks in advance
Upvotes: 1
Views: 1081
Reputation: 12317
There is inserted table, but it can be only used with output
clause, with something like this:
insert into samantha (id , name)
output inserted.*
values (11,'has')
If you have an identity field and you want the latest value from it, you can use SCOPE_IDENTITY() -function too:
insert into samantha (id , name)
values (11,'has')
select SCOPE_IDENTITY()
Upvotes: 4