Executing Exe files from SQLServer

  • Does anyone knows how to execute a exe file from SqlServer ( Stored Procedure / Dts / Job ) ?

    Thanks

    HM


    Helder Martins

  • Take a look at xp_cmdshell in BOL.

    The example there

    exec master.dbo.xp_cmdshell 'dir *.exe'

    shows the results from the server directory, not your local computer.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • here another tips...

    --T-SQL

    declare @retval int

    exec @retval = master.dbo.xp_cmdshell 'c:\program files\myapp\myapp.exe'

    print @retval

    if @retval = 0 then the execution was succefully

    -- JOB

    You may use Operating System Command (CmdExec) option from 'Edit Job Step' windows

    or You may use T-SQL option and use the same first sample (xp_cmdshell), but, in that case don`t have a result of execution. Results for execution of job, always be succefully in tha case

     

    --DTS

    You may use the 'Execute Process Task' object

    :.::.:.::

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

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