运行master数据库下的 xp_cmdshell这个存储过程。eg:
exec master..xp_cmdshell 'dir c:\'

解决方案 »

  1.   

    xp_cmdshell
    以操作系统命令行解释器的方式执行给定的命令字符串,并以文本行方式返回任何输出
    示例
    A. 返回可执行文件列表
    下例显示执行目录命令的 xp_cmdshell 扩展存储过程。EXEC master..xp_cmdshell 'dir *.exe'B. 使用 Windows NT net 命令
    下例显示 xp_cmdshell 在存储过程中的使用。下例先用 net send 通知用户 SQL Server 即将关闭,然后用 net pause 暂停服务器,最后用 net stop 关闭服务器。CREATE PROC shutdown10
    AS
    EXEC xp_cmdshell 'net send /domain:SQL_USERS ''SQL Server shutting down 
       in 10 minutes. No more connections allowed.', no_output
    EXEC xp_cmdshell 'net pause sqlserver'
    WAITFOR DELAY '00:05:00'
    EXEC xp_cmdshell 'net send /domain: SQL_USERS ''SQL Server shutting down 
       in 5 minutes.', no_output
    WAITFOR DELAY '00:04:00'
    EXEC xp_cmdshell 'net send /domain:SQL_USERS ''SQL Server shutting down 
       in 1 minute. Log off now.', no_output
    WAITFOR DELAY '00:01:00'
    EXEC xp_cmdshell 'net stop sqlserver', no_output