Created
May 20, 2019 01:03
-
-
Save ArCiGo/be3d296deeb9e3c26f52929a1eed8fef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF EXISTS(SELECT 1 FROM sys.procedures WHERE name = 'spCustomerIns') | |
DROP PROC spCustomerIns | |
GO | |
CREATE PROC spCustomerIns( | |
@pId INT OUT, | |
@pFirstName NVARCHAR(MAX), | |
@pLastName NVARCHAR(MAX), | |
@pCity NVARCHAR(MAX), | |
@pCountry NVARCHAR(MAX), | |
@pPhone NVARCHAR(MAX) | |
) | |
AS | |
BEGIN | |
SELECT @pId = ISNULL(MAX(cus.Id), 0) + 1 FROM Customer cus | |
INSERT INTO Customer(Id, FirstName, LastName, City, Country, Phone) | |
VALUES(@pId, @pFirstName, @pLastName, @pCity, @pCountry, @pPhone) | |
END | |
GO | |
SELECT * | |
FROM Customer | |
/** Output **/ | |
Id FirstName LastName City Country Phone | |
----------- ---------------------------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- | |
... | |
90 Matti Karttunen Helsinki Finland 90-224 8858 | |
91 Zbyszek Piestrzeniewicz Warszawa Poland (26) 642-7012 | |
93 Jean-Guy Lauzon Montréal Canada (514) 555-9022 | |
94 Chantal Goulet Ste-Hyacinthe Canada (514) 555-2955 | |
SET IDENTITY_INSERT Customer ON | |
EXEC spCustomerIns 95, 'Pascual', 'DiBella Nava', 'Tampico', 'México', '212-98-43' | |
-- SET IDENTITY_INSERT Customer OFF | |
SELECT * | |
FROM Customer | |
/** Output **/ | |
Id FirstName LastName City Country Phone | |
----------- ---------------------------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- | |
... | |
90 Matti Karttunen Helsinki Finland 90-224 8858 | |
91 Zbyszek Piestrzeniewicz Warszawa Poland (26) 642-7012 | |
93 Jean-Guy Lauzon Montréal Canada (514) 555-9022 | |
94 Chantal Goulet Ste-Hyacinthe Canada (514) 555-2955 | |
95 Pascual DiBella Nava Tampico México 212-98-43 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment