SQL Server Stored Procedure - DELETE - Example
Source code to create and add sql delete stored procedure to
catalog
The following example is for creating a simple delete stored
procedure. You can run it through an explicit call from a host language
program or directly from a DBMS query execution shell like SQL Server
Management Studio or dbOrchestra.
IF ( OBJECT_ID('dbo.sp_Students_DEL_byPK') IS NOT NULL )
DROP PROCEDURE dbo.sp_Students_DEL_byPK
GO
CREATE PROCEDURE dbo.sp_Students_DEL_byPK
@student_id INT
AS
BEGIN
SET NOCOUNT ON
DELETE dbo.Students
FROM dbo.Students
WHERE
student_id = @student_id
END
GO
Executing the sql delete stored procedure
Execute sql delete stored procedure
To run the stored procedure you need to supply a values to the
applicable variables.
-- @student_id IN INT
EXEC dbo.sp_Students_DEL_byPK
@student_id = 25
GO
Link to schema for Students table
|