Learn how to create STORE PROCEDURE in SQL Server. Below is a basic Example.

USE [MyDB]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SP_Parent]
@Id int
,@ParentName nvarchar(50)
AS
BEGIN TRAN
SET @Id = (SELECT ISNULL(MAX(Id),0) FROM Parent) + 1

INSERT INTO Parent (Id, ParentName)
    VALUES (@Id, @ParentName)

SELECT * FROM Parent WHERE Id=@Id
COMMIT TRAN