Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

Hi all,

 

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).

 

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

 

Any help would be appreciated

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...