定义信息查询如存储过程参数-INFORMATION_SCHEMA


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
1, INFORMATION_SCHEMA.COLUMNS :存储列定义,包含列类型,长度等信息。
2,INFORMATION_SCHEMA.PARAMETERS:存储过程参数信息。
如:查询行长度:
select
c.table_name,
count(*) columns,
sum(
case data_type
when 'binary' then character_maximum_length
when 'varbinary' then character_maximum_length
when 'char' then character_maximum_length
when 'varchar' then character_maximum_length
when 'nchar' then character_maximum_length
when 'nvarchar' then character_maximum_length
when 'bigint' then 8
when 'int' then 4
when 'uniqueidentifier' then 16
when 'datetime' then 8
when 'bit' then 1
when 'image' then 16
when 'text' then 16
when 'ntext' then 16
end) as avgLen
 from INFORMATION_SCHEMA.COLUMNS c join INFORMATION_SCHEMA.Tables t
ON c.Table_Schema=t.Table_Schema AND c.Table_Name=t.Table_Name
WHERE t.TABLE_TYPE='BASE TABLE' AND c.TABLE_NAME NOT IN('dtproperties','sysdiagrams')
--AND table_name like '%log'
group by c.table_name
order by avgLen desc
go