Q:

Must declare the table variable "@FruitCrates"

I am trying to create a stored procedure which will accept a table value parameter and then use merge to add new records, leave ones already there and delete the ones already there but not provided by me, this is what I am trying,
Alter procedure [dbo].[InsertMultipleFruits]
(
    @FruitCrates As Fruits_CratesType READONLY
)
AS

GO
DECLARE @I INT;

BEGIN
    MERGE INTO Fruits_Crates AS TARGET
    USING(SELECT FruitID, CrateID FROM @FruitCrates) AS SOURCE
        ON (TARGET.FruitID = SOURCE.FruitID)
    WHEN MATCHED THEN
        UPDATE 
            SET @I = 1  --- i want nothing to happen here ---
    WHEN NOT MATCHED BY TARGET THEN
        INSERT (FruitID, CrateID)
        VALUES (SOURCE.FruitID, SOURCE.CrateID)
    WHEN NOT MATCHED BY SOURCE THEN
        DELETE;
END

I am getting error,

...Line 5 Must declare the table variable "@FruitCrates". 
  Msg 156, Level 15, State 1, Line 10 Incorrect syntax near the keyword 'WHEN'.

I already created the table type but not sure why getting error.

A:

Don't put go between the procedure declaration and the body.  Try this:
Alter procedure [dbo].[InsertMultipleFruits]
(
    @FruitCrates As Fruits_CratesType READONLY
)
AS
BEGIN
    DECLARE @I INT;
    MERGE INTO Fruits_Crates AS TARGET
    USING(SELECT FruitID, CrateID FROM @FruitCrates) AS SOURCE
        ON (TARGET.FruitID = SOURCE.FruitID)
    WHEN MATCHED THEN
        UPDATE 
            SET @I = 1  --- i want nothing to happen here ---
    WHEN NOT MATCHED BY TARGET THEN
        INSERT (FruitID, CrateID)
        VALUES (SOURCE.FruitID, SOURCE.CrateID)
    WHEN NOT MATCHED BY SOURCE THEN
        DELETE;
END;

