classDemo 发表于 2013-2-4 19:45:17

系统存储过程

--                                  系统存储过程


--1:所有的系统存储过程以"sp"开头,位于master数据库中
--
--2:常用的系统存储过程有:

--(1)exec sp_databases--查询所有数据库
--
--(2)exec sp_helpdb--有关数据库的信息
--
--(3)exec sp_renamedb    --修改数据库名字
--
--(4)exec sp_tables--当前环境下可查询的对象的列表
--
--(5)exec sp_columns 'authors' --查看某个表的列信息
--
--(6)exec sp_help 'authors'--查看某个表的所有信息
--
--(7)exec sp_stored_procedures--查看所有的列名
--
--(8)exec sp_password--添加或修改登录帐户的密码
--
--(9)exec sp_helptext --显示默认值,没有加密的存储过程,用户自定义的存储过程,触发器或视图
--
--(10)exec xp_cmdshell DOS命令--系统的一个常用的扩展存储过程,以xp开头,
--                              可以完成DOS命令下的一些操作 如:exec xp_cmdshell 'mkdir d:\hh'
--这个就是创建一个文件夹在d:盘的叫hh的文件夹
--

use pubs
go
--查询某个表的所有列头名字的sql语句

--select name from syscolumns where id=(select id from sysobjects where name='authors')
--select c.name from syscolumns c, sysobjects o where o.name='authors'and c.id=o.id
页: [1]
查看完整版本: 系统存储过程