在sql中有一个表Stu_qx:
qx_bm qx_mc
01    龙泉
02    金牛
03    武侯
.......
现在在程序中得到一个字符串:01+02
现在问题是如何通过存储过程对01+02这个字符串进行处理后返回给程序的是龙泉,金牛
谢谢!!!!!1

解决方案 »

  1.   

    --> 测试数据: [Stu_qx]
    if object_id('[Stu_qx]') is not null drop table [Stu_qx]
    go
    create table [Stu_qx] (qx_bm varchar(2),qx_mc varchar(4))
    insert into [Stu_qx]
    select '01','龙泉' union all
    select '02','金牛' union all
    select '03','武侯'declare @s varchar(20) ,@s1 varchar(30)
    set @s='01+02'select @s1=isnull(@s1+',','')+qx_mc from [Stu_qx]
    where charindex('+'+qx_bm+'+','+'+@s+'+')>0
    select @s1------------------------------
    龙泉,金牛(1 行受影响)