获取SQL所有数据库名、所有表名、所有字段名、表字段长度
1.获取所有数据库名:
Select Name FROM Master..SysDatabases orDER BY Name
2.获取所有表名:
Select Name FROM DatabaseName..SysObjects Where XType='U' orDER BY Name
XType='U':表示所有用户表;
XType='S':表示所有系统表;
3.获取所有字段名:
Select Name FROM SysColumns Where id=Object_Id('TableName')
4、表字段的长度
select
table_name ,
column_name,
isnull(column_default,'') default_value,
is_nullable,
data_type,
isnull(isnull(isnull(character_maximum_length,numeric_precision),datetime_precision),1) length
from information_schema.columns
where not table_name in('sysdiagrams','dtproperties')
Select Name FROM Master..SysDatabases orDER BY Name
2.获取所有表名:
Select Name FROM DatabaseName..SysObjects Where XType='U' orDER BY Name
XType='U':表示所有用户表;
XType='S':表示所有系统表;
3.获取所有字段名:
Select Name FROM SysColumns Where id=Object_Id('TableName')
4、表字段的长度
select
table_name ,
column_name,
isnull(column_default,'') default_value,
is_nullable,
data_type,
isnull(isnull(isnull(character_maximum_length,numeric_precision),datetime_precision),1) length
from information_schema.columns
where not table_name in('sysdiagrams','dtproperties')