zoukankan      html  css  js  c++  java
  • sql 语句

    declare @strtrannote nvarchar(100);
    declare @strlocation nvarchar(100);
    declare @tempstr nvarchar(100);
    set @strtrannote='a*b*'set @strlocation='1*2*';
    set @tempstr=@strlocation
    DECLARE @Index int;
    DECLARE @Left nvarchar(50);
    WHILE CHARINDEX('*',@strtrannote> 0--返回字符串中指定表达式的起始位置
     BEGIN
      
    SELECT @Index = CHARINDEX('*',@strtrannote);--返回字符串中第一个"&"的起始位置
      SELECT @Left = LEFT(@strtrannote,@Index-1);--从左边开始,取得字符串左边指定个数的字符(第一个值)
      --update TranNote set packlist_id=@packlist_id where TranNotekey=@LEFT and website=@website;
        DECLARE @Index2 int;
        
    DECLARE @Left2 nvarchar(50);
      
    set @strlocation=@tempstr
        
    WHILE CHARINDEX('*',@strlocation> 0--返回字符串中指定表达式的起始位置
            BEGIN
                
    SELECT @Index2 = CHARINDEX('*',@strlocation);--返回字符串中第一个"&"的起始位置
                SELECT @Left2 = LEFT(@strlocation,@Index2-1);--从左边开始,取得字符串左边指定个数的字符(第一个值)
                    print(@left);
                    
    print(@left2);
                
    SELECT @strlocation = REPLACE(@strlocation,@Left2+'*','');--将左边已经取出的部分替换为空
            END
      
    SELECT @strtrannote = REPLACE(@strtrannote,@Left+'*','');--将左边已经取出的部分替换为空

     END

    显示结果:

    a
    1
    a
    2
    b
    1
    b
    2

  • 相关阅读:
    nginx 配置优化(简单)
    Nginx 安装
    Smokeping安装教程
    test [ ] 四类
    if语句中的判断条件(nginx)
    力扣 1431. 拥有最多糖果的孩子 python
    力扣 1672. 最富有客户的资产总量+1512. 好数对的数目 python
    力扣 剑指 Offer 58
    力扣 8. 字符串转换整数 (atoi)python--每日一题
    力扣 7. 整数反转python 每日一题
  • 原文地址:https://www.cnblogs.com/lfzwenzhu/p/1332905.html
Copyright © 2011-2022 走看看