Problem with xp_cmdshell

  • Hi there, hope in your help.

    I need to save in my hard disk the txt file generated with this code, can you help me?

    thank you.

    The error is:

    “The configuration option ‘xp_cmdshell’ does not exist, or it may be an advanced option.”

    EXEC sp_configure 'xp_cmdshell';

    EXEC xp_cmdshell 'bcp "SELECT

    *

    FROM

    tkt

    " queryout "c:\temp\test.txt" -T -c -t,';

  • -- xp_cmdshell is an advanced option,

    -- so first you need to check if it's turned on:

    EXEC sp_configure;

    GO

    -- If you don't see xp_cmdshell in the list:

    EXEC sp_configure 'show advanced options', 1;

    RECONFIGURE;

    GO

    -- Check the status of xp_cmdshell.

    -- If necessary turn xp_cmdshell on:

    EXEC sp_configure 'xp_cmdshell', 1;

    RECONFIGURE;

    GO

    -- Do stuff

    -- If xp_cmdshell is no longer needed:

    EXEC sp_configure 'xp_cmdshell', 0;

    RECONFIGURE;

    GO

    -- If advanced options are no longer needed:

    EXEC sp_configure 'show advanced options', 0;

    RECONFIGURE;

    GO

  • thanks a lot!

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

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