I have written the following procedure and I can't get it to save as Visual Studio keeps telling me that 'there's an error near '('', which isn't very helpful...
Any ideas why this is happening? It is supposed to try and update a row, if it doesn't exist then insert it instead (it is a more efficient way than running a select command then running an update or an insert command, as it only calls indexes once).
Any help would be appreciatedCode:CREATE PROCEDURE dbo.InsertPupil @FirstName varchar(100), @LastName varchar(100), @AdmissionNumber varchar(10), @FreeMeals integer, @Photo image, @PupilType integer AS UPDATE People SET(FirstName=@FirstName, LastName=@LastName, FreeMeals=@FreeMeals, Photo=@Photo, TypeID=@PupilType) WHERE AdmissionNumber=@AdmissionNumber IF @@ROWCOUNT=0 INSERT INTO People (FirstName, LastName, AdmissionNumber, FreeMeals, Photo, TypeID) VALUES (@FirstName, @LastName, @AdmissionNumber, @FreeMeals, @Photo, @PupilType) RETURN
Don't mind me. The answer was very simple... There shouldn't be any parentheses around the data after SET in the UPDATE command.
There are currently 1 users browsing this thread. (0 members and 1 guests)