如 tb 中有:
a b c ... temp1 temp2 ...
1 3 2 0 6
7 2 10 3 8
如用 select * from tb 就将表中所有列选择了.
但我只要 除了 temp 之前的列,这语句是如何写呢?
得到:
a b c ...
1 3 2
7 2 10
谢谢!
sql select
------解决方案--------------------
select a,b,c,…… from tb
------解决方案--------------------
如果因为满足你的要求,写出的代码比"select a,b,c,…… from tb" 还复杂,请问你要了还有何意义。
------解决方案--------------------
如果列很多的话可以考虑拼接sql
------解决方案--------------------
似乎只能一一列举...
------解决方案--------------------
不想一一列举,就只能用拼接SQL.
用以下方法取出相应表的字段:
select b.name as tables,a.name as field
from sys.syscolumns a left join sys.sysobjects b on a.id=b.id
where b.xtype in ('U','V') and b.name='表名' and a.name not like 'temp%'