xp_cmdshell

  • Trying to do this

    EXEC master..xp_cmdshell 'bcp "SELECT * FROM tablename" queryout "c:\testfile_20111010.txt" -c -T'

    getting this error

    Msg 229, Level 14, State 5, Procedure xp_cmdshell, Line 1

    The EXECUTE permission was denied on the object 'xp_cmdshell', database 'mssqlsystemresource', schema 'sys'.

    Any ideas how to resolve this?

  • You might need to enable the XP_CMDSHELL option using this:

    sp_configure 'xp_cmdshell',1

    reconfigure with override

    But, be aware that enabling this might make your SQL server vulnerable and if you are using it on a Production server, you might want to disable it after your BCP is complete

    sp_configure 'xp_cmdshell',0

    reconfigure with override

  • There is a very nice discussion going on SSC on use of xp_cmdshell.

    http://qa.sqlservercentral.com/Forums/Topic1186236-1526-1.aspx#bm1187660

    Donโ€™t miss it. ๐Ÿ˜‰

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

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