USE SQLCMD mode in SQL Job step

  • Hi Folks. 1. I am gathering data into one central table from different server using SQLCMD mode in SSMS.

    2. I need to schedule this in SQL job. so my first step is to capture Data , in SQL step I put step name, and in type I selected Operating system(CmdExec). But it is failing.

    So How to use SQLCMD mode in job step ?

    Sagar Sonawane
    ** Every DBA has his day!!:cool:

  • If I'm reading this right, I would change the strategy. there might be additional details why you HAVE to go SQLcmd, but i'll start with my assumption.

    instead of stepping out to the command line and running SQLCmd, and trying to wrestle the data back into SQL,

    I think it would add a linked server to the same server with the same credentials being used, and insert results into a temp table locally, for further consumption.

    SELECT *

    --INTO #Results

    FROM OPENQUERY( [MyLinkedServer],'SELECT * FROM MyDatabase.dbo.TableName ')

    SELECT *

    --INTO #Results

    FROM [MyLinkedServer].MyDatabase.dbo.TableName

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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