求一条SQL语句 - MS-SQL Server / 基础类
表名: teacher 字段分别有 序号,姓名,年龄,性别,年收入…………
现想求一条SQL语句是 除了"序号"这个字段不显示,其他字段均显示的语句, 并非 select 姓名,年龄,性别,年收入…………
from teacher 这条语句(因为字段假设有30多个会写死人的)谢谢!
用动态SQL
SQL code:
DECLARE @s VARCHAR(8000)
SELECT @s = ISNULL(@s+',', '')+name
from syscolumns
WHERE id = OBJECT_ID('teacher')
AND name<>'序号'
EXEC ('SELECT '+@s+' from teacher')
参考:
SQL code:
得到表中除Col1、Col2的所有列
例如:userno_fm、userno_to
create table test(
num int identity(1,1),
userno_fm varchar(10),
userno_to varchar(10),
username varchar(10))
select * from test
declare @sql varchar(8000)
select @sql=''
select @sql=@sql+','+[name] from
(select [name] from syscolumns where object_id(N'[test]')=[id] and [name] not in ('userno_fm','userno_to')) A
set @sql='select '+stuff(@sql,1,1,'')+' from [test]'
--print @sql
exec (@sql)
drop table test
SQL code:
declare @sql varchar(8000)
select @sql=''
select @sql=@sql+','+[name] from
(selec
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......
如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP
参考:http://hi.baidu.com/toiota ......
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......