zoukankan      html  css  js  c++  java
  • 某列根据逗号分割 转行

     select  ServiceStaff, * from Project_Hdr where Id=12

    原查询结果   'XM2053,XM205'

    执行下面语句

    select
    code=substring(a.ServiceStaff,b.number,charindex(',',a.ServiceStaff+',',b.number+1)-b.number),*
    from Project_Hdr a,
    master..spt_values b
    where b.type='p' and b.number<=len(a.ServiceStaff)
    and substring(a.ServiceStaff,b.number,1)<>',' and substring(','+a.ServiceStaff,b.number,1)=','
    and Id=12

    得到结构

  • 相关阅读:
    Investment
    The Fewest Coins
    Bone Collector II
    Cow Exhibition
    饭卡
    A + B Problem II
    F
    敌兵布阵
    单例模式
    面向对象
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/2918033.html
Copyright © 2011-2022 走看看