sql server 2005 xp_cmdshell

  • Hi,

    is there someone who knows how to leave out the NULL in the output window of let's say for example following script:

    exec master..xp_cmdshell 'C:\scripts\sql\test.bat test.sql'

    kind regards,

    bryan

  • The NULL is the blank line that the command shell is printing. It is not coming from SQL Server or the xp_CmdShell procedure, it is coming from DOS itself.

    If you really want to filter them out though, you can do something like this:

    CREATE Proc spExec_DOSCmdWoNulls as

    CREATE Table #dos([out] Varchar(max));

    INSERT into #dos([out])

    Exec master..xp_cmdshell 'C:\scripts\sql\test.bat test.sql';

    SELECT [out]

    From #dos

    Where Not [out] is Null

    DROP Table #dos

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Thanks,

    just what i needed.

    kind regards,

    bryan

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

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