Syntax issue with Update query



  • I am creating a Create Procedure that will be used to update a table with Update with Parameters query.

    The problem I am having is with the syntax for some reason, it errors when I place a comma between two fields. If I put a comma like suppose it errors the rest of the statement. If I remove 1 comma between fields, then it errors on some of the fields with the = @Parametername. What am I missing? See Attached picture.

    Any assistance you can offer is greatly appreciated.

    Thanks,

    Karen enter image description here

        CREATE PROCEDURE dbo.UpdateUsers
    

    @User_ID int
    ,@FirstName varchar(250)
    ,@LastName varchar(250)
    ,@FullName varchar(250)
    ,@EMail varchar(250)
    ,@UserRoles varchar(250)
    ,@PostionType varchar(250)
    ,@ManagerID int
    ,@UUID varchar(250)
    ,@External_UUID varchar(250)
    ,@home_Location_id int
    ,@Home_Location_Name varchar(250)
    ,@Home_Organization_ID int
    ,@Home_Organization_Name varchar(250)
    ,@Record_types varchar(250)
    ,@Location_Ceiling_ID int
    ,@Location_Ceiling_Name varchar(250)
    ,@Organization_Ceiling_ID int
    ,@Payroll_Identifier varchar(250)
    ,@Created_Date datetime
    ,@Update_Date datetime
    ,@Audit_Date datetime

    AS

    BEGIN

    SET NOCOUNT ON;

    update [dbo].[tblUsers_DIM]
    set
    [Name] = @FirstName
    ,[LastName] = @LastName
    , [FullName] = @FullName
    , [EMail] = @EMail
    [UserRoles] = @UserRoles
    [PostionType] = @PostionType
    , [ManagerID] = @ManagerID
    , [UUID] = @UUID
    , [External_UUID] = @External_UUID
    , [home_Location_id] =@home_Location_id
    , [Home_Location_Name]=@Home_Location_Name
    , [Home_Organization_ID] = @Home_Organization_ID
    , [Home_Organization_Name] = @Home_Organization_Name
    , [Record_types] =@Record_types
    , [Location_Ceiling_ID] = @Location_Ceiling_ID
    , [Location_Ceiling_Name] =@Location_Ceiling_Name
    , [Organization_Ceiling_ID] =@Organization_Ceiling_ID
    , [Payroll_Identifier] =@Payroll_Identifier
    , [Created_Date] =@Created_Date
    , [Update_Date] =@Update_Date
    , [Audit_Date] =@Audit_Date
    Where [User_ID] =@User_ID
    END



  • Turns out if was a simple mistake I had in on the wrong database. when I placed it on the correct db it worked once I added the commas.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2