zoukankan      html  css  js  c++  java
  • sql server 拆分字符串,拆分两次(:和;)

     declare @DisciplineID int            
     declare @paramStringVal nvarchar(1000) 
     declare @NPNT nvarchar(100) 
     declare @DisciplineMapping nvarchar(100)
     declare @UEIDCount int
     declare @NPNTDisciplineMapping nvarchar(100)
     declare @rownum2 int
     declare @split nvarchar(1000)
     set @split=';'
     select @paramStringVal=ParamStringVal from   ODM_Parameter where ParameterID='NPNTandDisciplineMapping'
    
     创建临时表:
      DECLARE @Temp TABLE    
            (    
             value  VARCHAR(100)    
            )   
            
    创建临时表: DECLARE @Temp1 TABLE ( NPNTCode VARCHAR(
    100) ,DisciplineCode VARCHAR(100) ) insert into @Temp select B.id AS value FROM ( SELECT [value] = CONVERT(XML , '<v>' + REPLACE(@paramStringVal , @split , '</v><v>') + '</v>') ) A OUTER APPLY ( SELECT id = N.v.value('.' , 'varchar(100)') FROM A.[value].nodes('/v') N ( v ) ) B 将临时表@Temp拆分后的数据(NPNTCode,DisciplineCode)插入到@Temp1临时表
    insert into @Temp1 SELECT substring(value,
    1,patindex('%:%',value)-1) as NPNTCode, substring(value,patindex('%:%',value)+1,len(value)) as DisciplineCode from @Temp --NPNTID select @DisciplineID=a2.DisciplineID from @Temp1 a inner join ODM_CDNPNT a1 on a.NPNTCode=a1.NPNT1 inner join ODM_CDDiscipline a2 on a.DisciplineCode=a2.Code1 where a1.ID=@NPNTID
  • 相关阅读:
    我的WCF之旅(1):创建一个简单的WCF程序
    网页设计中颜色的搭配
    CSS HACK:全面兼容IE6/IE7/IE8/FF的CSS HACK
    UVa 1326 Jurassic Remains
    UVa 10340 All in All
    UVa 673 Parentheses Balance
    UVa 442 Matrix Chain Multiplication
    UVa 10970 Big Chocolate
    UVa 679 Dropping Balls
    UVa 133 The Dole Queue
  • 原文地址:https://www.cnblogs.com/liuwj/p/4635594.html
Copyright © 2011-2022 走看看