日期:2014-05-18  浏览次数:20416 次

求救啊!谁能写出简单的sql语句来查询表中的列!
简单的就行了不要太复杂的呀

比如表名是   text

其中有   id   name   aaa   ccc   bbb
5个列!怎么才能才查询分析器里直接查询text表的列呢!
或许是在asp里写出的话怎么实现啊!

大家帮帮我吧

------解决方案--------------------
create table [text](id int,name varchar(10),aaa int,ccc int,bbb int)
go

select name from syscolumns where id=object_id( 'text ')
go

/*
name
---------
aaa
bbb
ccc
id
name
*/

drop table [text]
go
------解决方案--------------------
--表名
select name from sysobjects
where type= 'U '
--字段名
select name from syscolumns
where id=object_id( '表名 ')

------解决方案--------------------
那如果不知道ID的话怎么查询呢!
-------------------------------------------------
不需要知道ID,只要知道表名就可以用以下系统函数获得表的ID:OBJECT_ID( '表名 ')