Search code examples
sql-serversql-server-2000xp-cmdshell

SQL Server 2000 xp_cmdshell


Using SQL Server 2000 I am trying to use this command in Query Analyzer

xp_cmdshell 'del c:\delete-me-file.txt'

and I'm getting this error:

Server: Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'xp_cmdshell'.

Basically I want to delete this file from the system... what command do I need to run to do this?


Solution

  • You need to be in the context of the master database or prefix the extended stored procedure with the db name.

    EXEC master..xp_cmdshell 'del c:\delete-me-file.txt' 
    

    If this command succeeds it would indicate that the SQL Server service account probably has too many permissions however.