sqlcmd code in stored procedure

  • Hi

    My qusetion:

    i want export Table data to text file usind sqlsmd?

    but i have to run sqlcmd code from stored proc..

    i am able to export data using below command at command prompt:

    sqlcmd -S server1 -U testuse -P test@123 -d citidb -Q "select * from

    [table1](nolock)" -o "MyData.txt"

    but how can put the above code in Stored procedure

    so that i can execute that sprocedure..

    i dont want to use Xp_cmdshell in Stored procedure

  • If you don't want to use xp_cmdshell then

    1. Create a job with step of Type Operating system (CmdExec) and type you sqlcmd command in that.

    2. Then from the stored proc execute sp_start_job to start that job.

    -Vikas Bindra

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

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