select b.name 表名,a.name 字段名 from syscolumns a join sysobjects b on a.id=b.id where b.xtype = 'U'
xtype 是表的性质,U是用户表,系统表是S
--查询所有表名
select name from dbo.sysobjects where xtype='u' and (not name LIKE 'dtproperties')
--查询所有表的所有字段名
SELECT dbo.sysobjects.name as Table_name, dbo.syscolumns.name AS Column_name
FROM dbo.syscolumns INNER JOIN
dbo.sysobjects ON dbo.syscolumns.id = dbo.sysobjects.id
WHERE(dbo.sysobjects.xtype = 'u') AND (NOT (dbo.sysobjects.name LIKE 'dtproperties'))
--查询指定表的所有字段名
SELECT dbo.sysobjects.name as Table_name, dbo.syscolumns.name AS Column_name
FROM dbo.syscolumns INNER JOIN
dbo.sysobjects ON dbo.syscolumns.id = dbo.sysobjects.id
WHERE dbo.sysobjects.name='表名'and (dbo.sysobjects.xtype = 'u') AND (NOT (dbo.sysobjects.name LIKE 'dtproperties'))
Last modification:November 25th, 2019 at 05:25 pm
如果觉得我的文章对你有用,请随意赞赏