Stored Procedure Executing Twice

  • Hi everyone ,

    i have a problem in executing a certain procedure that returns a value on a remote server. i am currently using the following statement:

    declare @ServerName varchar(50)

    declare @v1 int

    set @ServerName = 'ALT1.clt_dev.dbo.proc_i_ICTG_New_Request'

    exec @v1 = @ServerName @v_benmobno = "123445", @v_AcNo ="12144", @c_Cur = "AED",  select @v1

    the procedure is supposed to insert into a table ... the record is inserted twice ..! it works fine when "select @v1" isnt there but the problem is that the return value doesnt show up ...

  • Try removing the comma. For example:

    declare @ServerName varchar(50)

    declare @v1 int

    set @ServerName = 'ALT1.clt_dev.dbo.proc_i_ICTG_New_Request'

    exec @v1 = @ServerName @v_benmobno = "123445", @v_AcNo ="12144", @c_Cur = "AED"

    select @v1

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • sorry that was a mistype  !!

    i would really appreciate it if someone would help me out...

  • I would suggest either posting your stored procedure or profiling the execution and finding out where the problem lies.  Your procedure call does not appear to be the culprit here. 

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Are tehre any triggers on the table? If so, what are they?

    Selecting @v1 will not cause it to eecute a second time.


    My blog: SQL Soldier[/url]
    SQL Server Best Practices:
    SQL Server Best Practices
    Twitter: @SQLSoldier
    My book: Pro SQL Server 2008 Mirroring[/url]
    Microsoft Certified Master: SQL Server, Data Platform MVP
    Database Engineer at BlueMountain Capital Management[/url]

  • What is the evidence that the procedure is executing twice?

    Could it be executing once but producing unexpected results?

    What happens if you call the procedure from SQA? Does it still execute twice?

    What happens if you insert debug statements into the code?

    Can you include the stored procedure code please?

    David

    If it ain't broke, don't fix it...

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

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