--SQL查询每个表的字段数量select b.[name], count(*) As AllCount,ISNULL(ISNULL(sum(case when isnullable=0 then 1 end),null),null) as NotNullCountfrom syscolumns aINNER JOIN( select [id], [name] from [sysobjects] where [type] = 'u' ) AS b ON a.id = b.[id] GROUP b…
查询指定表结构的表名.列名.类型.说明.字段长度 select o.name as tableName,c.name as columnName,t.name as columnType,p.value as columnDescription,c.prec from sysobjects o left join syscolumns c on o.id=c.idleft join sys.extended_properties p on p.major_id=c.id and p.mino…
SQL查询一个表中类别字段中Max()最大值对应的记录 SELECT A.id, A.name, A.version FROM DOC A, (SELECT id, MAX(version) AS version FROM DOC GROUP BY id) AS B WHERE A.id = B.id AND A.version = B.version…
最近在研究PHP,那么就必须涉及到mysql.其中一个功能通过表数据自动生成页面,紧接着发现在一张空表中无法读取数据(因为人家刚刚新建,就是空的没有数据) 延伸出来便是直接查表结构获得字段名,再进行处理. SQL server 和MySQL 搜索表结构语句是不同的:SQL server:select * from syscolumns where id=(select id from sysobjects where name='T_tmp') MySQL: SELECT * FROM INFO…
SELECT 表名 then d.name else '' end, 表说明 then isnull(f.value,'') else '' end, 字段序号 = a.colorder, 字段名 = a.name, 标识 then '√'else '' end, 主键 FROM sysobjects where xtype='PK' and parent_obj=a.id and name in ( SELECT name FROM sysindexes WHERE indid in( SEL…