SQLCMD command needs parameter

  • I am trying to run following command but getting error like

    Procedure or function 'Procedure Name' expects parameter '@status', which was not supplied.

    declare

    @SQLCmd Varchar(1000)

    set @SQLCmd='Exec xp_cmdshell '+char(39)+'Sqlcmd -S scdc330db -d IDX_OPS -Q "exec SCP_AppStatus_Notify " -v @status="Start" -v @app="Analysis Data Distribution" -v @task="Test"'+char(39)

    Exec(@SQLCmd)

    Any help will be appreciated

  • Did you ever figure this one out?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • To me, it looks like you do not have anything that consumes the variables @status, etc.

    I have not tested this to ensure the syntax is correct, but you need something like

    set @SQLCmd='Exec xp_cmdshell '+char(39)+'Sqlcmd -S scdc330db -d IDX_OPS -Q "exec SCP_AppStatus_Notify @status=$(status),@app=$(app),@task=$(task) " -v status="Start" -v app="Analysis Data Distribution" -v task="Test"'+char(39)

    Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.

    When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara

Viewing 3 posts - 1 through 2 (of 2 total)

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