Running SQLCMD from SQL Server

  • I would like to use SQLCMD to run a large script stored locally on command. To do this, I would like to create a job with one step, in this step, I have two commands...

    sqlcmd -i " \Out1";

    sqlcmd -i " \Out2";

    I have the Type of job as Operating system (CmdExec). Is it possible to run sqlcmd from sql server 2005? Or do I have to run it from the cmd? I would like to be able to just create a job to run the commands, but I don't know if its possible. Please advise, thanks.

    -Kyle

  • I keep getting the error Incorrect syntax near 'i'. The label 'D' has already been declared. Label names must be unique within a query batch or stored procedure.

  • what does the input file contain

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • D:\MSSQL\MSSQL.1\Scripts\Test1.sql

    D:\MSSQL\MSSQL.1\Scripts\Test2.sql

  • try this

    sqlcmd -S servername -U username -P password -i "D:\MSSQL\MSSQL.1\Scripts\Test1.sql"

    sqlcmd -S servername -U username -P password -i "D:\MSSQL\MSSQL.1\Scripts\Test2.sql"

    you have to run these from cmdexe. If you want to schedule it, put these commands in a batch file and shedule execution of batch file.

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

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