CREATE PROCEDURE UpdateEmpPhonesRow
@IDToEdit int,
@Password nvarchar(44),
@NewFname nvarchar(20) = ??,
@NewLname nvarchar(40) = ??,
@NewPhone int = 9999
AS 
IF EXISTS (
SELECT Phone
FROM EmpPhones
WHERE EmployeeID = @IDToEdit
  AND Password = @Password
 )
BEGIN
 IF @NewFname <> ??
 UPDATE EmpPhones
 SET Fname = @NewFname
 WHERE EmployeeID = @IDToEdit
 IF @NewLname <> ??
 UPDATE EmpPhones
 SET Lname = @NewLname
 WHERE EmployeeID = @IDToEdit
 IF @NewPhone <> 9999
 UPDATE EmpPhones
 SET Phone = @ NewPhone
 WHERE EmployeeID = @IDToEdit
 RETURN -1
END
ELSE
RETURN 0

Поделитесь материалом с коллегами и друзьями