I am starting learning SQL server, and I don't understand the difference between SCOPE_IDENTITY(), @@IDENTITY
On my side, I have created a table and insert data using the below T-SQL
Create Table Test1 (ID int IDENTITY(1,1) ,Value nvarchar(20))
insert into Test1 values ('bb')
Then I run the below query
select SCOPE_IDENTITY()
select @@IDENTITY
I got the same result 1 and 1.
Could you please explain What's the difference between SCOPE_IDENTITY(), @@IDENTITY in SQL?