i am currently calling SELECT @@identity from VBA in mysql:
Set rs = cn.Execute("SELECT @@identity", , adCmdText)
but since i am going to be working with sql server db instead of mysql, i would like to know how to make this statement sql-server friendly
would it just be Set rs = cn.Execute("SCOPE_IDENTITY()", , adCmdText) ??
Both SQL statements are valid, with one exception. Change
to
The difference between the two is that the
@@identityvariable contains the most recent identity value on the SQL Server (global perspective). TheSCOPE_IDENTITY()function returns the most recent local identity.You can find more on the
SCOPE_IDENTITYhere.