下例显示 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
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
解决方案 »
- 用hibernate连接两个数据库
- 如何查询指定时间段内的数据?
- 求一sql語句
- 数据库 'tempdb' 的日志已满。请备份该数据库的事务日志以释放一些日志空间。
- 急呀!!!为什么我翻页的程序到了30页以后显示的都是一样的内容呀~~~~~~~~~~~~~
- 系统中如何处理客户资料等信息变更?
- 我想实现将指定字段field1里有相同的项去掉,只保留其中一个
- SQL 中两个表的关于时间的比较?
- select中文关键字网页查询结果不同?求解啊
- ADO+SQL SERVER+DCOM做的C/S三层程序,在客户端(win98)是否要装SQL SERVER CLIENT版?
- 怎样在客户机启动和停止SQL服务器
- 怎样在客户机启动和停止SQL服务器
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ 服务名是MSsqlSERVER
shell "command.com /c 内部命令名称"
或者
shell "cmd.com /c 内部命令名称"