trying to create procedure to call xp_cmdshell and sqlcmd to run script file

  • Hello everyone,

    I created the below sp but when I run it the output is "Sqlcmd: '-S': Unknown OPtion. Denter'-?' for help"

    code snippet

    CREATE PROCEDURE sp_eSiteProductionArchive

    AS

    EXEC master.dbo.xp_cmdshell "sqlcmd –S SQLSERVER760\MSSQLSERVERTEST -E -i C:\Documents and Settings\TWOCOCKS\My Documents\Script\Script.sql"

    Any suggestions on what I'm doing wrong here? Appreciate your help!

    Thanks

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • seandeyoung-1145978 (11/12/2009)


    Hello everyone,

    I created the below sp but when I run it the output is "Sqlcmd: '-S': Unknown OPtion. Denter'-?' for help"

    code snippet

    CREATE PROCEDURE sp_eSiteProductionArchive

    AS

    EXEC master.dbo.xp_cmdshell "sqlcmd –S SQLSERVER760\MSSQLSERVERTEST -E -i C:\Documents and Settings\TWOCOCKS\My Documents\Script\Script.sql"

    Any suggestions on what I'm doing wrong here? Appreciate your help!

    Thanks

    EXEC master.dbo.xp_cmdshell 'sqlcmd –S SQLSERVER760\MSSQLSERVERTEST -E -i "C:\Documents and Settings\TWOCOCKS\My Documents\Script\Script.sql" '

    I think that might help..

    CEWII

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

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