易截截图软件、单文件、免安装、纯绿色、仅160KB

求一句sql - MS-SQL Server / 疑难问题


a b
1 2  
2 2
3 2
4 2
5 2

where b=2 查询后结果为

1,2,3,4,5


SQL code:
select stuff((select a from tb where b=2 order by a for xml path('')),1,1,'')


SQL code:
declare @s varchar(8000)
set @s=''
select @s=@s+a+',' from tb where b=2


SQL code:
declare @s varchar(100)
select @s=isnull(@s+',','')+ltrim(a)from tb where b=2



SQL code:
--> 测试数据:[tb]
if object_id('[tb]') is not null drop table [tb]
create table [tb]([a] int,[b] int)
go
insert [tb]
select 1,2 union all
select 2,2 union all
select 3,2 union all
select 4,2 union all
select 5,2

select stuff((select ','+ltrim(a) from tb where b = t.b for xml path('')),1,1,'' )
from [tb] t
where b = 2
group by b

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

SQL如何优化问题 - MS-SQL Server / 疑难问题

今天做了一个存储过程   环境是SQL2000数据库  
大致如下
建立临时表
定义员工游标
        循环员工(属于1个公司)  
        ......

sql - MS-SQL Server / 疑难问题

sql的软件在哪里可以下啊!在网上找了蛮多都用不了啊

随便搞一D版吧,

迅雷第一个就可以用
2000,2005都这样

http://119.147.41.16/down?cid=0698C2D64D7D637D90A6D2482298E6717D4F15CD&t=2&fmt=-1 ......

vs2008 连接mysql? - MS-SQL Server / 基础类

请问
添加新数据源->数据库->添加连接
这个界面下,数据源选择:Microsoft SQL Server (SqlClient);
服务器名:
应该写什么呢?
有谁知道?多谢各位!!
你到底是要连mysql还是mssql?

引用
请问
......

SQL server分解XML - MS-SQL Server / 应用实例

下面是XML初始文件内容
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号