34,590
社区成员
发帖
与我相关
我的任务
分享
if OBJECT_ID('A') is not null drop table A
create table A(id int,col1 nvarchar(1),col2 nvarchar(1),col3 nvarchar(1),col4 nvarchar(1),col5 nvarchar(1))
declare @columnList varchar(2000) --字段列集合字符串
select @columnList=isnull(@columnList+',','')+name from syscolumns where id=OBJECT_ID('A') and name<>'id'
--输出列名
print @columnList --拿着去拼查询语句
drop table A
select id,grade=case when grade%2=0 then grade+10 else grade end
from tb
SELECT id ,
grade + CASE WHEN grade % 2 = 0 THEN 10
ELSE 0
END AS grade
FROM stu
select id,case grade%2 when 0 then grade+10 else grade end as grade from stu