declare @str varchar(8000) set @str='' select @str=@str+','+Name from syscolumns where id=object_id('ERPWorkToDo') set @str=stuff(@str,1,1,'') select @str --'ERPWorkToDo是表名本回答被网友采纳
第2个回答 2014-02-20
什么意思,听不明白是要取字段名,还是字段值追问
字段名
追答
mysql: SELECT COLUMN_NAME FROM 'information_schema'.'COLUMNS' where 'TABLE_SCHEMA'='数据库名称' and 'TABLE_NAME'='你的表名' order by COLUMN_NAME; oracle SELECT USER_TAB_COLS.COLUMN_NAME FROM USER_TAB_COLS t where t.TABLE_NAME='表名'