I'm using dynamic sql for insert data into dynamic table (.NET C#). I need to get the identity column value in return and I try to use scope_identity but the result always shows 1.
This is my code
dqDbContext dqx = new dqDbContext();
string queryHdr = "INSERT INTO " + tableHdrName + " VALUES ("
+ configId + ",'Administrator',GETDATE()); SELECT SCOPE_IDENTITY();";
int id = dqx.Database.ExecuteSqlCommand(queryHdr);
Is there something that I missing here?
Thanks
Felix