USE [Database]

IF OBJECT_ID('[Procedures].[insert_product]', 'P') IS NOT NULL
  DROP PROCEDURE [Procedures].[insert_product];
GO
CREATE PROCEDURE [Procedures].[insert_product]
  @name                 AS NVARCHAR(128),
  @product_type_id      AS INT,
  @barcode              AS BIGINT,
  @inserted_product_id  AS INT = NULL OUTPUT
AS
  BEGIN TRANSACTION;
    INSERT INTO [Tables].[products]([barcode], [name], [product_type_id])
    VALUES(@barcode, @name, @product_type_id);
    SET @inserted_product_id = SCOPE_IDENTITY();
  COMMIT TRANSACTION;
GO