I have some tables that i have created in SQL Server and i want to write a stored Procedure that will insert data on to one of my tables AND also be able to update say if i select record
CREATE PROCEDURE Sp_cust_SaveCustomer
--ALTER PROCEDURE cust_SaveCustomer
(@id int,
@ Surname varchar(50),
@ Initials varchar(50),
@ SEX_CODE varchar(50))
AS IF @id=-1
BEGIN INSERT INTO cust_Customer(Surname,Initials,SEX_CODE)
SELECT @ Surname,@ Initials,@SEX_CODE
SELECT @@identity
END
ELSE
BEGIN UPDATE cust_Customer
SET
Surname= @ Surname ,
Initials =@ Initials ,
SEX_CODE =@ SEX_CODE
WHERE id=@id
SELECT @id
END