Sqlserver
 sql >> Base de données >  >> RDS >> Sqlserver

MS SQL Server Dernier ID inséré

Essayez celui-ci -

DECLARE @ID BIGINT

INSERT INTO dbo.TABLE_ID (Table_NAME) 
SELECT 'Table_Products'

SELECT @ID = SCOPE_IDENTITY()

INSERT INTO dbo.Table_Products (ID, Product_Name)
SELECT @ID, 'SomeProduct'