For MS SQL Server:
SCOPE_IDENTITY()
will return you the last generated identity value within your current scope:
SELECT SCOPE_IDENTITY() AS NewID
More Related Contents:
- Is there AUTO INCREMENT in SQLite?
- Select first row in each GROUP BY group?
- SQLite – UPSERT *not* INSERT or REPLACE
- Auto Increment after delete in MySQL
- How can I list the tables in a SQLite database file that was opened with ATTACH?
- Update table values from another table with the same user name
- SQL Select between dates
- How to pivot in SQLite or i.e. select in wide format a table stored in long format?
- Foreign key referring to primary keys across multiple tables?
- How can I define a composite primary key in SQL?
- Exporting data In SQL Server as INSERT INTO
- SQLite – ORDER BY RAND()
- How can I insert values into a table, using a subquery with more than one result?
- Select random row(s) in SQLite
- INSERT rows into multiple tables in a single query, selecting from an involved table
- sqlite alter table add MULTIPLE columns in a single statement
- Drop all tables command
- SQL speed up performance of insert?
- SQL Server: Cannot insert an explicit value into a timestamp column
- SQL Server 2008 – Help writing simple INSERT Trigger
- How to create timestamp column with default value ‘now’?
- String concatenation does not work in SQLite
- Unfindable SQLite Syntax Error
- SQLite3 UNIQUE constraint failed error
- Does SQLite3 have prepared statements in Node.js?
- How to select the first N rows of each group?
- adding primary key to sql view
- Retrieve Oracle last inserted IDENTITY
- How to bulk insert only new rows in PostreSQL
- SQL Populate table with random data