Search code examples
sqlite

How to use scope_identity in sqlite


I have an issue using scope_identity in SQLite.

Query:

string txtSQLQuery = "insert into  SerpTrak_Site (SiteName) values ('" + txturl.Text +   "')select scope_identity();";

It's showing the error "select": syntax error. Is there anything wrong with this query?


Solution

  • SQLite does not have a function by the name scope_identity

    You are probably looking for 'SELECT last_insert_rowid()'

    See also this question: Does SQLite support SCOPE_IDENTITY?