I'm trying to learn SQL and I've run into a problem with stored procedures. I've got a tables structure like in the picture, where Repair.RepairerId
and Repair.CarId
are foreign keys for the appropriate tables.
What I need to do is to create a stored procedure that allows a user to delete entities from table Repair where user can select the car model and the repairer name in Microsoft SQL Server 2017.
For now I have the next code:
CREATE PROCEDURE [dbo].[DeleteRepairInfo]
@Name nvarchar(MAX),
@Model nvarchar(MAX)
AS
DELETE Repair.*
FROM Repair INNER JOIN Repairer ON Repair.RepairerId = Repairer.Id
INNER JOIN Car ON Repair.CarId = Car.Id
WHERE Car.Model LIKE @Model AND Repairer.Name LIKE @Name
GO
However SQL Editor in Visual Studio 2017 gives me the error:
SQL46010: Incorrect syntax near ..
Also all the INNER JOIN
statements and their =
signs are greyed out as well as words LIKE
, AND
, and the final LIKE
. (I'm not sure if this is okay).
You can see this on the next picture: