将一条记录中的字段拆成多条记录

    技术2022-05-11  120

       --删除测试     drop   table  #t

      --分拆处理     declare @i int     select @i=max(len(tpno)) from tr_job     set rowcount @i     select id=identity(int) into #t from syscolumns a,syscolumns b     set rowcount 0         select a.jobno  ,tpno=substring(a.tpno,b.id,charindex(',',a.tpno+',',b.id)-b.id)     from tr_job a,#t b     where b.id<=len(a.tpno) and substring(','+a.tpno,b.id,1)=','  


    最新回复(0)