SQLSERVER拆分逗号分隔的字段为多条数据

select
    a.ProjGuid,
    SUBSTRING(a.ZygwAllGUID,number,CHARINDEX(',',a.ZygwAllGUID+',',number)-number) as ZygwGUID,
    CjRoomTotal,
    QSDate 
from
   s_Contract as a,master..spt_values 
where
    number >=1 and number < len(a.ZygwAllGUID)  
    and type='p'
    and substring(','+a.ZygwAllGUID,number,1)=','

SQLSERVER拆分逗号分隔的字段为多条数据_第1张图片

你可能感兴趣的:(sqlserver,sql)