Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

SQL Server e C#:ottieni l'ultimo ID inserito

Clausola OUTPUT?

string query = "INSERT INTO SocialGroup (created_by_fbuid) 
                OUTPUT INSERTED.IDCol  --use real column here
                VALUES (@FBUID)";
...
int lastId = (int)command.ExecuteScalar();