Executing a script from SQL Server

  • Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/sjones/scriptscheduling.asp

  • Good article steve. Perhaps worth while mentioning how you can load up sql*server tables from the results of a external command being executed? I cant remember the exact syntax as its 2am and i had a screaming baby in my ear 🙂 but its a nice trick that i used when having to unzip a heap of files from a dir within t-sql.


    Chris Kempster
    www.chriskempster.com
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

  • I avoid putting the actual SQL in the steps because it creates a point of maintenance. I'd rather create a stored proc and change that if needed.

    ckempste:

    Not sure what you mean? Is this a BULK INSERT variation?

    Steve Jones

    steve@dkranch.net

  • Steve

    Hi Steve, I ment something like this:

    truncate table infile_list

    set @v_commandline = 'dir /B ' + @v_processeddest + '*.unl'

    insert into infile_list

    exec @result = master..xp_cmdshell @v_commandline

    Where ive sent the output of the xp_cmdshell to a table for later processing.

    Cheers

    Chris


    Chris Kempster
    www.chriskempster.com
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

  • That makes sense. I usually pipe to a file and then grep or findstr for any errors.

    Steve Jones

    steve@dkranch.net

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

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