SQL Server关于筛选列的问题

chikinglau 2003-09-29 05:23:21
请教各位大师:
我在用select 列 from 表 这一语句的时候,因为列有很多,现在我只是想不要其中一些列,比如:select A1,A2,A3....An from 表,我想把列A2和A3不筛选出来,这语句该怎么写呢?
...全文
85 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chikinglau 2003-09-29
  • 打赏
  • 举报
回复
谢谢大家
txlicenhe 2003-09-29
  • 打赏
  • 举报
回复
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 你的表名')
txlicenhe 2003-09-29
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2270/2270480.xml?temp=.9384424
/**** 多列中的某一列不查
declare @ varchar(8000)
set @=''
select @=@+rtrim(name)+',' from syscolumns where id=object_id('你的表名') and name not in ('你不要的列名1','你不要的列名1')
set @=left(@,len(@)-1)

exec('select '+@+' from 你的表名')
yujohny 2003-09-29
  • 打赏
  • 举报
回复
select A1,A4,A5……An from 表
这种方法是最快的解决方法了,当然可能不是最好的
txlicenhe 2003-09-29
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2270/2270480.xml?temp=.9384424
/**** 多列中的某一列不查

22,206

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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