SQL Server UPDATE Query errors

  • CREATE PROCEDURE [dbo].[update_table]

    -- Add the parameters for the stored procedure here

    @Referral_Method varchar(700),

    @Referral_Source varchar(700),

    @Original_Referral_Date varchar(700),

    @Current_Referral_Date varchar(700),

    @Primaryagency_Name varchar(700),

    @Primaryagency_Contact varchar(700),

    @Primaryagency_Address varchar(700),

    @Primaryagency_City varchar(700),

    @Primaryagency_State varchar(700),

    @Primaryagency_Zip varchar(700),

    @Primaryagency_Disnum varchar(700),

    @Primaryagency_num varchar(700),

    @Primaryagency_Fax varchar(700),

    @Primaryagency_email varchar(700),

    @Primaryagency_TTY varchar(700),

    AS

    BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON

    Declare @scope_Id int

    SET @scope_Id = SCOPE_IDENTITY()

    -- Insert statements for procedure here

    UPDATE dbo.[ATU Clients]

    SETReferral_Method = @Referral_Method,

    Referral_Source = @Referral_Source,

    Original_Referral_Date = @Original_Referral_Date,

    Current_Referral_Date = @Current_Referral_Date,

    [Primary_(PAS)_Agency_Name] = @Primaryagency_Name,

    Primary_Agency_Address = @Primaryagency_Address,

    Primary_Agency_City = @Primaryagency_City,

    Primary_Agency_State = @Primaryagency_State,

    Primary_Agency_Zip_Code = @Primaryagency_Zip,

    Primary_Agency_District# = @Primaryagency_Disnum,

    Primary_Agency# = @Primaryagency_num,

    Primary_Agency_Fax# = @Primaryagency_Fax,

    [Primary_Agency_E-Mail] = @Primaryagency_email

    WHERE ATU_ID = @scope_id;

    END

    GO

    I am getting the following error : Msg 156, Level 15, State 1, Procedure update_table, Line 24

    Incorrect syntax near the keyword 'AS'.

    Please help. Thanks

  • You have an extra comma at the end of the last parameter.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Any reason why you have varchar(700) for all your columns? That seems a little excessive.

    Any reason you're note using the correct datatypes. I can't recommend enough you get it fixed NOW rather than months down the road when it's too late or much harder to do.

  • I am still getting the same error. I have not put coma for the last parameter. I dont know which one you are referring to.

    I have made that to 50:hehe:. I was just being careful so as not to get error on them.

  • i think its the comma at the end of this parameter that is being mentioned.

    @Primaryagency_TTY varchar(700),

  • Oh my god!!! that was awesome thank you very much 😀

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply