Day 8(11.15):存储过程(3)--扩展存储过程
2015-11-15 16:49
274 查看
-- 3 ****************************************************
-- 扩展存储过程
-- 是 DLL 内的函数,用于增加 SQL Server 的功能,访问数据库外部例程,只能存在于 master 库中
-- 3.1 --------------------------------------------------
-- xp_logevent 在事件查看器中记录用户自定义信息
/*
xp_logevent {error_number, 'message'} [, 'severity']
error_number
是用户定义的大于 50,000 的错误号。最大值为 1073741823 (230 - 1)。
'message'
是少于 8,000 个字符的字符串。
'severity'
是以下三个字符串之一:INFORMATIONAL、WARNING 或 ERROR。severity 是可选的,其默认值为 INFORMATIONAL。
*/
exec master..xp_logevent 50001, 'xp_logevent_testing informational'
exec master..xp_logevent 50002, 'xp_logevent_testing warning','WARNING'
exec master..xp_logevent 50003, 'xp_logevent_testing error','ERROR'
-- 3.2 --------------------------------------------------
-- xp_cmdshell 执行给定的命令字符,作为操作系统命令,返回文本的输出参数
EXEC master..xp_cmdshell 'dir d:\'
EXEC master..xp_cmdshell 'md d:\DeleteMe'
EXEC master..xp_cmdshell 'echo a piece of cake >d:\DeleteMe\xp_cmdshell.txt'
EXEC master..xp_cmdshell 'net send 127.0.0.1 Windows is shuting down in 30 seconds! Please save your data.'
-- 练习 --------------------------------------------------
-- 1 使用 xp_cmdshell ,将刚才创建的 d:\DeleteMe\xp_cmdshell.txt 在原路径打包成 rar 文件,并加上密码 'TomSawyer'
-- 2 使用 xp_cmdshell ,在操作系统中生成 具有管理员权限的帐号:Tom 密码:TomSawyer
-- 扩展存储过程
-- 是 DLL 内的函数,用于增加 SQL Server 的功能,访问数据库外部例程,只能存在于 master 库中
-- 3.1 --------------------------------------------------
-- xp_logevent 在事件查看器中记录用户自定义信息
/*
xp_logevent {error_number, 'message'} [, 'severity']
error_number
是用户定义的大于 50,000 的错误号。最大值为 1073741823 (230 - 1)。
'message'
是少于 8,000 个字符的字符串。
'severity'
是以下三个字符串之一:INFORMATIONAL、WARNING 或 ERROR。severity 是可选的,其默认值为 INFORMATIONAL。
*/
exec master..xp_logevent 50001, 'xp_logevent_testing informational'
exec master..xp_logevent 50002, 'xp_logevent_testing warning','WARNING'
exec master..xp_logevent 50003, 'xp_logevent_testing error','ERROR'
-- 3.2 --------------------------------------------------
-- xp_cmdshell 执行给定的命令字符,作为操作系统命令,返回文本的输出参数
EXEC master..xp_cmdshell 'dir d:\'
EXEC master..xp_cmdshell 'md d:\DeleteMe'
EXEC master..xp_cmdshell 'echo a piece of cake >d:\DeleteMe\xp_cmdshell.txt'
EXEC master..xp_cmdshell 'net send 127.0.0.1 Windows is shuting down in 30 seconds! Please save your data.'
-- 练习 --------------------------------------------------
-- 1 使用 xp_cmdshell ,将刚才创建的 d:\DeleteMe\xp_cmdshell.txt 在原路径打包成 rar 文件,并加上密码 'TomSawyer'
-- 2 使用 xp_cmdshell ,在操作系统中生成 具有管理员权限的帐号:Tom 密码:TomSawyer
相关文章推荐
- Android之获取手机上的图片和视频缩略图thumbnails
- 数据库链接字符串查询网站
- DB2实例管理
- DB2实例管理
- 保障MySQL数据安全的14个最佳方法
- mysql问答汇集
- 创建一个空的IBM DB2 ECO数据库的方法
- Access 2000 数据库 80 万记录通用快速分页类
- 开通一个数据库失败的原因的和解决办法
- 一个简单的asp数据库操作类
- CentOS下DB2数据库安装过程详解
- EasyASP v1.5发布(包含数据库操作类,原clsDbCtrl.asp)第1/2页
- sql2008 还原数据库解决方案
- Oracle 数据库自动存储管理-安装配置
- Oracle 数据库 临时数据的处理方法
- 数据库分页查询语句数据库查询
- 最近比较流行的数据库挂马
- Oracle 手动创建数据库步骤详解
- 分割超大Redis数据库例子