查询Access字段名的SQL语句怎么写?

问题一:查询出表内所有的字段名(表名为:TestTable)。
第二个问题:2)、查询出TestTable表内第3列的字段名(如果支持请回答)。

因为使用C#开发,所以必须用SQL语句实现,请高手赐教!
感谢以上两位的关注,但请看清问题,我要查询的是字段的名称(例如数据库里有ID、Account,Password等字段,我要查询的就是这些字段名),而不是表名也不是数据值。
例如在SQL Server中可以使用语句select name from syscolumns where id = object_id('TestTable');来实现,而Access中没有syscolumns函数所以这段语句实现不了,请高手赐教啊!

SQL SERVER

查看所有表名:
select name from sysobjects where type='U'

查询表的所有字段名:
Select name from syscolumns Where ID=OBJECT_ID('表名')

select * from information_schema.tables
select * from information_schema.views
select * from information_schema.columns

ACCESS

查看所有表名:
select name from MSysObjects where type=1 and flags=0

MSysObjects是系统对象,默认情况是隐藏的。通过工具、选项、视图、显示、系统对象可以使之显示出来。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-06-15
第一题:select ID,Account,Password from TestTable
第二题:select top 1 * from TestTable where id in(select top 3 id from TestTable order by id asc)order by id desc或select top 1 * from TestTable where id not in(select top 3 id from TestTable )

查什么字段我写的 * (星) 那就写什么字段呗,用逗号隔开。追问

我要查的就是字段的名字,而不是字段的内容。查询出来的结果应该是字段名。

第2个回答  2011-06-17
SQL SERVER

查看所有表名:
select name from sysobjects where type='U'

查询表的所有字段名:
Select name from syscolumns Where ID=OBJECT_ID('表名')

select * from information_schema.tables
select * from information_schema.views
select * from information_schema.columns

ACCESS

查看所有表名:
select name from MSysObjects where type=1 and flags
第3个回答  2011-06-21
既然用了C#,你为什么不非得用SQL去取字段名?用dt.Columns(i).ColumnName不就好了嘛本回答被提问者采纳
第4个回答  2011-06-15
查字段名 where id等于一个空值 如:0 不就只显示字段不显示值了