指引网

当前位置: 主页 > 数据库 > SQLServer >

sqlserver查询所有表名、字段名、类型、长度和存储过程、视图的创建语句

来源:网络 作者:佚名 点击: 时间:2018-03-14 07:58
[摘要] -- 获得存储过程创建语句select o xtype,o name,cm text from syscomments cm inner join sysobjects o on o id=cm id where xtype = 39;p 39;order by o xtype,o name,cm text-- 获
-- 获得存储过程创建语句
select o.xtype,o.name,cm.text from syscomments cm 
inner join sysobjects o on o.id=cm.id 
where xtype ='p'
order by o.xtype,o.name,cm.text



-- 获得视图程创建语句
select o.xtype,o.name,cm.text from syscomments cm 
inner join sysobjects o on o.id=cm.id 
where xtype ='v'
order by o.xtype,o.name,cm.text



-- 查询所有表名、字段名、类型、长度
select o.name, c.name,t.name,c.length from syscolumns c
inner join systypes t on c.xtype= t.xtype
inner join sysobjects o on c.id= o.id
where   o.xtype='u' 
order by  o.name, c.name,t.name

-- 所有数据都来自于这四张表
--select * from sysobjects	
--select * from syscolumns
--select * from syscomments
--select * from systypes


------分隔线----------------------------