select cast(A as varchar(10))
+cast(A as varchar(10))
+cast(A as varchar(10))
+cast(A as varchar(10))
+cast(A as varchar(10))
from tb
where A is not null
and B is not null
and c is not null
and d is not null
and e is not null
+cast(A as varchar(10))
+cast(A as varchar(10))
+cast(A as varchar(10))
+cast(A as varchar(10))
from tb
where A is not null
and B is not null
and c is not null
and d is not null
and e is not null
解决方案 »
- 数据库设计问题
- 求助:如何在符合条件的字符串中查找匹配的字符串?
- 【求助】写了一个时间转换函数有错误求改之
- 事务回滚问题,事务提交返回值问题??????????明天必须搞定,救命
- je的字段属性为decimal,为什么<%=rs("je")*0.4%>和<%=rs("je")*cdbl(0.4)%>都没显示??
- COUNT(*)是全表查询吗
- 第一次接触 sql 提速问题,请教一下?(100分啊)
- SQL语句问题?
- 如何使用SQL语句复制数据库对象
- sql 根据起始推过程
- 用户定义的函数里面可以用exec sp_executesql执行语句返回值吗
- 想取出满足不同ID的AA列中最大值的各个记录,怎么写
select top 1 isnull(convert(varchar,A01),'')+isnull(convert(varchar,A02),'')+isnull(convert(varchar,A03),'')+isnull(convert(varchar,A04),'')+isnull(convert(varchar,A05),'')+isnull(convert(varchar,A06),'')+isnull(convert(varchar,A07),'')+isnull(convert(varchar,A08),'')+isnull(convert(varchar,A09),'')+isnull(convert(varchar,A10),'') from TB
select
stuff((case when A01 is null then '' else '+'+rtrim(A01) end) +
(case when A02 is null then '' else '+'+rtrim(A02) end) +
(case when A03 is null then '' else '+'+rtrim(A03) end) +
...
(case when A10 is null then '' else '+'+rtrim(A10) end), 1,1,'')
from
T
isnull(convert(varchar,A01),'')+
(case when A01 is not null then '+' else '' end)+
isnull(convert(varchar,A02),'')+
(case when A02 is not null then '+' else '' end)+
isnull(convert(varchar,A03),'')+
(case when A03 is not null then '+' else '' end)+
isnull(convert(varchar,A04),'')+
(case when A04 is not null then '+' else '' end)+
isnull(convert(varchar,A05),'')+
(case when A05 is not null then '+' else '' end)+
isnull(convert(varchar,A06),'')+
(case when A06 is not null then '+' else '' end)+
isnull(convert(varchar,A07),'')+
(case when A07 is not null then '+' else '' end)+
isnull(convert(varchar,A08),'')+
(case when A08 is not null then '+' else '' end)+
isnull(convert(varchar,A09),'')+
(case when A09 is not null then '+' else '' end)+
isnull(convert(varchar,A10),'')
from tb
from tb
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([ID] int,[A01] varchar(1),[A02] varchar(1),[A03] varchar(1),[A04] varchar(1),[A05] varchar(1),[A06] varchar(1),[A07] varchar(1),[A08] varchar(1),[A09] varchar(1),[A10] varchar(1))
insert [tb]
select 2,'A',null,null,'B',null,'C','D',null,null,'E'
---查询---
select
isnull(A01+'+','')
+isnull(A02+'+','')
+isnull(A03+'+','')
+isnull(A04+'+','')
+isnull(A05+'+','')
+isnull(A06+'+','')
+isnull(A07+'+','')
+isnull(A08+'+','')
+isnull(A09+'+','')
+isnull(A10,'')
AS 显示结果
from [tb]---结果---
显示结果
-------------------
A+B+C+D+E(所影响的行数为 1 行)
select
isnull(A01+'+','')
+isnull(A02+'+','')
+isnull(A03+'+','')
+isnull(A04+'+','')
+isnull(A05+'+','')
+isnull(A06+'+','')
+isnull(A07+'+','')
+isnull(A08+'+','')
+isnull(A09+'+','')
+isnull(A10,'')
AS 显示结果
from tb t
where not exists(select * from tb where id>t.id)