Error 8144 - Too Many Arguments Specified

  • I am receiving this error Error 8144 - Too Many Arguments Specified when running a stored procedure. Here is the code maybe someone will see something obvious. I am new to this so am sure it's something that i have done wrong.

    Thanks for any help

    USE [wce_sqlexpress]

    GO

    /****** Object: StoredProcedure [dbo].[activity_delete] Script Date: 09/29/2008 09:56:47 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER procedure [dbo].[activity_delete]

    @activityid varchar(16)

    AS

    declare @atype varchar(100)

    declare @creationtime datetime

    declare @contactid varchar(25)

    declare @duration varchar(50)

    declare @subject varchar(50)

    declare @notes varchar(254)

    declare @utable varchar(50)

    set @atype = (SELECT atype FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    set @creationtime = (SELECT createtime FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    set @contactid = (SELECT createuser FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    set @duration = (SELECT duration FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    set @subject = (SELECT subject FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    set @notes = (SELECT notes FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    set @utable = 'wce_history'

    UPDATE wce_linkto SET LUTABLENAME = @utable WHERE LUNIQUEID = @ACTIVITYID

    INSERT INTO wce_history (uniqueid, ATYPE, CREATETIME, CREATEUSER, DURATION, SUBJECT, NOTES, EDITTIME, EDITUSER, RECORDEDFOR, RECORDEDTIME)

    VALUES (@ACTIVITYID, @atype, @creationtime, @contactid, @duration, @subject, @notes, @creationtime, @contactid, @contactid, @creationtime)

    DELETE FROM wce_activity where uniqueid = @ACTIVITYID

  • How many arguments are you passing when you run this stored procedure?

    This stored procedures accepts only one arguments.

  • I am only passing the activityid. The rest i am selecting from the activity table inside the procedure.

  • Hi Sergio

    I can't see why you are getting an error, however I can see that only one SELECT is required to fetch the data for your history table:

    [font="Courier New"]USE [wce_sqlexpress]

    GO

    /****** Object:  StoredProcedure [dbo].[activity_delete]    Script Date: 09/29/2008 09:56:47 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [dbo].[activity_delete]

    @activityid VARCHAR(16)

    AS

    --declare @atype varchar(100)

    --declare @creationtime datetime

    --declare @contactid varchar(25)

    --declare @duration varchar(50)

    --declare @subject varchar(50)

    --declare @notes varchar(254)

    --declare @utable varchar(50)

    --set @atype = (SELECT atype FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    --set @creationtime = (SELECT createtime FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    --set @contactid = (SELECT createuser FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    --set @duration = (SELECT duration FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    --set @subject = (SELECT subject FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    --set @notes = (SELECT notes FROM wce_activity WHERE UNIQUEID = @ACTIVITYID)

    --set @utable = 'wce_history'

    UPDATE wce_linkto SET LUTABLENAME = 'wce_history' WHERE LUNIQUEID = @ACTIVITYID

    INSERT INTO wce_history (uniqueid, ATYPE, CREATETIME, CREATEUSER, DURATION, SUBJECT, NOTES, EDITTIME, EDITUSER, RECORDEDFOR, RECORDEDTIME)

    SELECT UNIQUEID, ATYPE, CREATETIME, CREATEUSER, DURATION, SUBJECT, NOTES, CREATETIME, CREATEUSER, CREATEUSER, CREATETIME

    FROM wce_activity

    WHERE UNIQUEID = @ACTIVITYID

    --VALUES (@ACTIVITYID, @atype, @creationtime, @contactid, @duration, @subject, @notes, @creationtime, @contactid, @contactid, @creationtime)

    DELETE FROM wce_activity WHERE uniqueid = @ACTIVITYID

    [/font]

    Cheers

    ChrisM

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • Thanks for your help, i found the issue it was a silly one, the arguments hadn't saved so it was passing two not one.

    Chris you taught me two things, firstly how to comment out in SQL and secondly how to merge an insert and select query.

    Thank you all very much.

  • You're welcome Sergio, thank you for your feedback.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

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

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