刚接触SQL SERVER,
现在有个数据表中存的是不规则地址,有些数据含有邮编,有些没有,请问用什么SQL语句把这个表里面的邮政编码删除?
谢谢

解决方案 »

  1.   

    update biao set 邮政编码=''
      

  2.   

    用charindex函数 去查查联机丛书
      

  3.   

    select * from tb where charindex(',',列)>0
      

  4.   

    用charindex函数判断位置 用substring函数截取 你不给出具体数据我也没办法帮忙哦
      

  5.   

    declare @s varchar(80)
    set @s='北京,100001'
    select stuff(@s,patindex('%[1-9][0-9][0-9][0-9][0-9][0-9]%',@s),6,'')/*
    北京,(所影响的行数为 1 行)
    */
      

  6.   

    update 表 set 字段=stuff(字段,patindex('%[1-9][0-9][0-9][0-9][0-9][0-9]%',@s),6,'')
      

  7.   

    update 表名set 邮政编码=''
      

  8.   

    不知道 等高手if exists (select * from sysobjects where name='aaaa')
    drop table aaaa
    create table aaaa
    (inf char(200),city char(200))
    insert into aaaa 
    select ',,北京,200001,,','北京'update aaaa
    set inf= case when inf like '%北京%'+'%[1-9][0-9][0-9][0-9][0-9][0-9]%' or inf like '%[1-9][0-9][0-9][0-9][0-9][0-9]%'+'%北京%'
    then '北京' end drop table aaaa