+ Post New Thread
Results 1 to 2 of 2
Coding Thread, MSSQL Procedure issue in Coding and Web Development; Hi all, I have written the following procedure and I can't get it to save as Visual Studio keeps telling ...
  1. #1

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    18,373
    Thank Post
    525
    Thanked 2,613 Times in 2,019 Posts
    Blog Entries
    24
    Rep Power
    891

    MSSQL Procedure issue

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

    Code:
    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

  2. #2

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    18,373
    Thank Post
    525
    Thanked 2,613 Times in 2,019 Posts
    Blog Entries
    24
    Rep Power
    891
    Don't mind me. The answer was very simple... There shouldn't be any parentheses around the data after SET in the UPDATE command.



SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 8
    Last Post: 5th April 2009, 09:57 AM
  2. SIMS and MSSQL
    By interele in forum MIS Systems
    Replies: 2
    Last Post: 25th November 2008, 07:35 PM
  3. Returns procedure
    By j17sparky in forum General Chat
    Replies: 8
    Last Post: 24th January 2008, 07:21 PM
  4. MSSQL Trigger (i think) Question
    By k-strider in forum Coding
    Replies: 3
    Last Post: 28th November 2006, 01:15 PM
  5. Replies: 19
    Last Post: 4th May 2006, 07:49 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •