sql server关于表和表结构的一些查询语句

1.查询出数据库中,当前登录用户下的表名

select name from sys.objects where type='U',或者

select name from sysobjects where xtype='u' and status>=0 

2.查询一个表的字段名

select name from syscolumns where id=object_id(''表名)

3.查询一个表的字段名和字段类型

select column_name,data_type from information_schema.columns where table_name='Department'

3.查询一个表的详细信息,包括创建时间,表结构,字段类型,字段长度

sp_help 表名 或者 sp_help '表名'

4.查询出数据库中的存储过程

select name as procedureName from sysobjects where xtype='P'


猜你喜欢

转载自blog.csdn.net/hhw199112/article/details/79636217