why i can't run this syntax

  • Hi,

    i want to check if the xp_cmdshell option not on then start it.

    so i write this syntax and i get an error.why?

    THX

    if not exists (select name from sys.configurations where name = 'xp_cmdshell' and value_in_use = 1)

    (

    EXEC sp_configure 'show advanced options', 1

    RECONFIGURE

    EXEC sp_configure 'xp_cmdshell', 1

    RECONFIGURE

    )

  • Try replacing your parentheses with BEGIN and END around your statement block...

    http://msdn.microsoft.com/en-us/library/ms182717.aspx

  • avipenina (7/21/2008)


    so i write this syntax and i get an error.why?

    THX

    this should do it

    if not exists (select name from sys.configurations where name = 'xp_cmdshell' and value_in_use = 1)

    begin

    EXEC sp_configure 'show advanced options', '1'

    RECONFIGURE

    EXEC sp_configure 'xp_cmdshell', '1'

    RECONFIGURE

    end

    EXEC sp_configure 'show advanced options', '0'

    RECONFIGURE

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Thx.

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

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