zoukankan      html  css  js  c++  java
  • 用临时表来分隔特殊符号(如逗号)的字符串

     1declare @Menu_id varchar(250)
     2declare @pos int 
     3declare @oldPos int 
     4declare @tempstr varchar(100
     5
     6
     7create table #temp_id ( id int ) 
     8
     9set @Menu_id = '60,62,63,64'
    10set @pos=1 
    11set @oldPos=1 
    12while @pos<len(@Menu_id
    13begin 
    14    set @pos=charindex(',',@Menu_id@oldpos
    15    if @pos>0 
    16    begin 
    17        set @tempstr=substring(@Menu_id,@oldpos,@pos-@oldpos
    18        set @oldpos=@pos+1 
    19    end 
    20    else 
    21    begin 
    22        set @tempstr=substring(@Menu_id,@oldpos,len(@Menu_id)-@oldpos+1
    23        set @pos=len(@Menu_id
    24    end 
    25    insert into #temp_id  values@tempstr )
    26end 
    27if len(@Menu_id)  = 1
    28    insert into #temp_id  values@Menu_id )
    29
    30select id from #temp_id
    31drop table #temp_id 
  • 相关阅读:
    scp上传服务器文件
    svn一次添加所有未添加的文件
    vue 去掉#和拼接参数
    vuex状态管理
    获取页面iframe里的元素
    angular 中ng-bind-html 、$scope服务
    心态崩了
    day 8
    day 7
    day6 angularjs学习
  • 原文地址:https://www.cnblogs.com/sonicit/p/1045752.html
Copyright © 2011-2022 走看看