I declared a variable of a custom type in a stored procedure but still getting error "must declare scalar variable"
<p>I created a custom  table type</p>

<pre><code>Create type dbo.InsertPatient as table
(SSN Int,
 LastUpdated Datetime,
 PatientId varchar(50),
 McdNo varchar(50),
 mcrno varchar(50)
)
GO
</code></pre>

<p>I tried to declare an input parameter using this type</p>

<pre><code>Create PROCEDURE [dbo].[proc_PatientDt_Insert]
(
    @PatientTable InsertPatient READONLY,
    @FacilityID int,
    @IsDeleted bit = 0
)
AS
BEGIN
    SET NOCOUNT OFF
    DECLARE @Err int

    IF(@IsDeleted = 1)
    BEGIN
        DELETE FROM [Patient]
        WHERE LTRIM(RTRIM([Patientid])) = LTRIM(RTRIM(@PatientTable.PatientId))
          AND FacilityID = @FacilityID

        RETURN
    END

    SET @Err = @@Error

    RETURN @Err
END
</code></pre>

<p>When I try to execute, I get this error </p>

<blockquote>
  <p>Msg 137, Level 16, State 1, Procedure proc_PatientDt_Insert, Line 18<br>
  Must declare the scalar variable "@PatientTable".  </p>
</blockquote>