数据库 查询字段

--查看所有表名:
select name from sysobjects where type='U'


--查询表的所有字段名:

Select name from syscolumns Where ID=OBJECT_ID('表名')


select * from information_schema.tables

select * from information_schema.views

select * from information_schema.columns

 

 


--表的字段名称
select name from syscolumns where id=object_id( '表名 ')
--表的字段数
select count(name) from syscolumns where id=object_id( '表名 ')
最好改成:object_id(N '表名 ')
这样只是规范一些,一般不会出错
select name from syscolumns where id=object_id('表名')--查出来哪个表的列名
select name from sysobjects where xtype= 'U '--查出来的是表名
select name from sysobjects where xtype= 'P '--存储过程

 

posted @ 2017-07-28 11:47  天晴微笑  阅读(304)  评论(0编辑  收藏  举报