SELECT SCOPE_IDENTITY() : SCOPE_IDENTITY « Sequence Indentity « SQL Server / T-SQL Tutorial






1> CREATE TABLE customer
2> (
3> cust_id      smallint        IDENTITY(100, 20)  NOT NULL,
4> cust_name    varchar(50)     NOT NULL
5> )
6> GO
1>
2> INSERT customer (cust_name) VALUES ('AAA Gadgets')
3> SELECT SCOPE_IDENTITY()
4> GO

(1 rows affected)

----------------------------------------
                                     100

(1 rows affected)
1>
2> drop table customer;
3> GO








15.7.SCOPE_IDENTITY
15.7.1.Last identity value generated for any table in the current session, for the current scope
15.7.2.Using the SCOPE_IDENTITY() Function
15.7.3.SELECT SCOPE_IDENTITY()