菜鸟问题,怎样从*中除去几列不想要的列??

ghosthjt 2003-12-15 07:39:37
比如 select * from table 会选出所有列,但能否这样?选出除去其中某一列field1外的所有其它列??这在不知道具体表字段,而只知道其中一定有字段的时候非常有用!
...全文
86 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ghosthjt 2003-12-16
  • 打赏
  • 举报
回复
但是如果是动态生成的列,在syscolumns里有记录吗,或者临时表也有吗?
dlpseeyou 2003-12-15
  • 打赏
  • 举报
回复
select name from syscolumns where id=object_id('数据库') and name not in ('不想显示的字段')
txlicenhe 2003-12-15
  • 打赏
  • 举报
回复
declare @ varchar(8000)
set @=''
select @=@+rtrim(name)+',' from syscolumns where id=object_id('你的表名') and name not in ('你不要的列名1','你不要的列名2')
set @=left(@,len(@)-1)

exec('select '+@+' from 你的表名')
youngby 2003-12-15
  • 打赏
  • 举报
回复
select '你想要的列' from table
youngby 2003-12-15
  • 打赏
  • 举报
回复
select col1,col2,col3,col4,col5 from table

34,837

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧