--注:t_Users 表名 T_Users 数据库名
--2014年8月25日11:31:40
--获取所有数据库名
SELECT Name FROM Master..SysDatabases ORDER BY Name
--.获取指定数据库的所有表名
use T_User
SELECT Name FROM SysObjects Where XType='U' ORDER BY Name
--获取指定表的所有字段名
use T_User
SELECT Name FROM SysColumns WHERE id=Object_Id('t_Users')
--获取数据库所有类型
use T_User
select name from systypes
--获取主键字段
use T_User
SELECT name FROM SysColumns WHERE id=Object_Id('t_Users') and colid=(select top 1 keyno from sysindexkeys where id=Object_Id('t_Users'))
--获取字段类型
use T_User
select a.name as [column],b.name as type from syscolumns a,systypes b where a.id=object_id('t_Users') and a.xtype=b.xtype
--取表结构
use T_User
select column_name,data_type,character_maximum_length from information_schema.columns where table_name = 't_Users'
sqlserver 查询数据库名 表名 字段名 字段类型等
最新推荐文章于 2024-06-19 16:02:33 发布