I want to create a procedure to update a table but I'm getting this error:
(68,1): SQL72014: .Net SqlClient Data Provider:
Message 137, Level 16, State 1, Procedure updatePatient, Line 11
Must declare the scalar variable "@pPatient".
Here is the procedure I am trying to create:
CREATE PROCEDURE [dbo].[updatePatient]
@pPatient PatientTableType readonly
AS
BEGIN
UPDATE Patient
SET Patient.Cel = @pPatient.Cel,
Patient.Address = @pPatient.Address,
Patient.NamePatient = @pPatient.NamePatient,
Patient.Phone = @pPatient.Phone
WHERE Patient.idPatient = @pPatient.idPatient
END
Here is the type that I created:
CREATE TYPE [dbo].[PatientTableType] AS TABLE
(
[idPatient] SMALLINT NOT NULL,
[NamePatient] VARCHAR(250) NOT NULL,
[Cellular] INT NULL,
[Phone] INT NULL,
[Address] VARCHAR(250) NULL
);
Here is the table that I want to update:
CREATE TABLE [dbo].[Patient]
(
[idPatient] SMALLINT NOT NULL,
[NamePatient] VARCHAR(250) NOT NULL,
[Cel] INT NULL,
[Phone] INT NULL,
[Address] VARCHAR(250) NULL,
PRIMARY KEY CLUSTERED ([idPatient] ASC)
);
What did I do wrong? How can I fix it?
Thanks in advance!