2.1 Get all the table names in the database
Sample data:
select t.name '表名' from sysobjects t where OBJECTPROPERTY(t.id, N'IsUserTable') = 1
或者用select name from sysobjects where type='U'
Results of the:
2.2 Get all field names in all tables
Statement:
select distinct c.name '字段名' from sysobjects t, syscolumns c
where t.id = c.id and OBJECTPROPERTY(t.id, N'IsUserTable') = 1
Results of the:
Note: Fields more, slightly behind
2.3 to view all the tables and fields
语句:select t.name '表名' ,c.name '字段名' from sysobjects t, syscolumns c
where t.id = c.id and OBJECTPROPERTY(t.id, N'IsUserTable') = 1 group by t.name,c.name
Results of the:
Note: Fields more, slightly behind
2.4 check all the fields to a table
Table_1 raw data:
语句:
select t.name,c.name '字段名' from sysobjects t, syscolumns c
where t.id = c.id and OBJECTPROPERTY(t.id, N'IsUserTable') = 1
and t.name='Table_1'
Results of the:
Table 2.5 check field belongs (i.e., containing the same table to find the field)
Query names are listed in the table which have
Statement:
select distinct t.name from sysobjects t, syscolumns c
where t.id = c.id and OBJECTPROPERTY(t.id, N'IsUserTable') = 1
and c.name in ('姓名')
Results of the:
Reproduced in: https: //www.cnblogs.com/zhangchenliang/archive/2011/05/29/2062040.html