SQL Insert Stored Procedure - Insert Stored Procedure in SQL Server



INSERT Stored Procedure

  • ALTER PROCEDURE using INSERT

Demo wikitechydatabase

  • Below is a selection from the wikitechytable table used in the examples:
insert-procedure-table

Example

  • ALTER PROCEDURE using Insert
ALTER PROCEDURE GetDataSP
(
@id INTEGER
@name VARCHAR(10),
@course VARCHAR(10),
@fees INTEGER,
@StatementType NVARCHAR(20) = ''
)
AS
BEGIN
  BEGIN
      IF @StatementType = 'Insert'
          INSERT INTO wikitechytable (id, name, coure, fees)
          VALUES (@id, @name, @coure, @fees)
  END
END

Output

insert-stored-procedure

Execute PROCEDURE using INSERT

EXEC GetDataSP @id=110, @name='Ajay', @course = 'SQL' , @fees=200, @StatementType = 'Insert' ;

Output

call-insert-stored-procedure


Related Searches to SQL Insert Stored Procedure - Insert Stored Procedure in SQL Server