sql语句如何把IP地址中的.去掉?
比如11.33.55.123  变成 113355123

解决方案 »

  1.   

    select replace('11.33.55.123','.','')
      

  2.   

    declare @ip varchar(20)
    select @ip='11.33.55.123'
    SELECT @ip=REPLACE(@ip,'.','')
      

  3.   

    select replace('127.0.0.1', '.', '')
      

  4.   

    那我这个数据是表里的
    比如表为xtable,字段名为ip,怎么办
      

  5.   

    --哈哈
    declare @ip varchar(20),@newip varchar(20),@L int
    select @ip='11.33.55.123',@newip=''
    SELECT @L=len(@ip)
    while @L>0
    begin
    set @newip=@newip+case when left(right(@ip,@L),1)='.' then '' else left(right(@ip,@L),1)  end
    set @l=@l-1
    end
    print @newip
      

  6.   

    select replace(ip,'.','') ip from xtable
      

  7.   

    update xtable set ip=replace(ip, '.', '')