Procedimientos CREATE
El procedimiento Create realiza la sentencia INSERT, la cual creará un nuevo registro. Tiene un parámetro para cada columna en la tabla:
IF OBJECT_ID('cusp_CustomerCreate') IS NOT NULL BEGIN DROP PROC usp_CustomerCreate END GO CREATE PROCEDURE usp_CustomerCreate @FirstName varchar(20), @LastName varchar(20), @Email varchar(20), @PhoneNumber int AS BEGIN INSERT INTO Customer ( FirstName, LastName, Email, PhoneNumber) VALUES ( @FirstName, @LastName, @Email, @PhoneNumber) SET @CustomerID = SCOPE_IDENTITY() SELECT FirstName = @FirstName, LastName = @LastName, Email = @Email, PhoneNumber =@PhoneNumber FROM Customer WHERE CustomerID = @CustomerID END |
---|
IF OBJECT_ID('cusp_CustomerRead') IS NOT NULL BEGIN DROP PROC cusp_CustomerRead END GO CREATE PROC cusp_CustomerRead @CustomerID int AS BEGIN SELECT CustomerID, FirstName, LastName, Email, PhoneNumber FROM Customer WHERE (CustomerID = @CustomerID) END GO |
---|
IF OBJECT_ID('cusp_CustomerUpdate') IS NOT NULL BEGIN DROP PROC cusp_CustomerUpdate END GO CREATE PROC cusp_CustomerUpdate @CustomerID int, @FirstName varchar(20), @LastName varchar(20), @Email varchar(20), @PhoneNumber int AS BEGIN UPDATE Customer SET FirstName = @FirstName, LastName = @LastName, Email = @Email, PhoneNumber = @PhoneNumber WHERE CustomerID = @CustomerID END GO |
---|
IF OBJECT_ID('cusp_CustomerDelete') IS NOT NULL BEGIN DROP PROC cusp_CustomerDelete END GO CREATE PROC cusp_CustomerDelete @CustomerID int AS BEGIN DELETE FROM Customer WHERE CustomerID = @CustomerID END GO |
---|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod Lorem ipsum dolor sit amet.