to: playyuer(心上人) 
什么意思?能详细点吗??
用replace好像没用吧

解决方案 »

  1.   

    update A set tem=(case when exists(select 1 from t2 where deptcode like A.deptcode+'_%') then null else 1 end) from t2 A
      

  2.   

    select depcode,(select count(*) as a
                      from #t 
                     where depcode like '%' + a.depcode + '%'
                           and a.depcode <> depcode
                    )
    from #t a
      

  3.   

    select (case when exists(select 1 from t1 where deptcode like A.deptcode+'_%') then null else 1 end) as tem,deptcode from T1 A
      

  4.   


    select depcode,(select count(*) as a
                      from #t 
                     where depcode like a.depcode + '_%'
                          --and a.depcode <> depcode
                    )
    from #t aselect depcode,(select count(*) as a
                      from #t 
                     where len(replace(depcode,a.depcode,'')) <> len (depcode)
                           and a.depcode <> depcode
                    )
    from #t a
      

  5.   

    J老师可以的:select (case when exists(select 1 from t1 where deptcode like A.deptcode+'_%') then null else 1 end) as tem,deptcode from T1 A
      

  6.   

    最简单:select (select 1 from t1 where deptcode like A.deptcode+'_%') tem,deptcode from T1 A
      

  7.   

    select  distinct a.deptid
    from t a join t b on a.deptid<>b.deptid
    where CHARINDEX(a.deptcode,b.deptcode)>=1找到 2 3 4 7 9列需要改为null
      

  8.   

    select (select max(1)
                      from #t 
                     where depcode like a.depcode + '_%'
                           -- and a.depcode <> depcode
                    ) as tem ,depcode 
    from #t a
      

  9.   

    看错题目,哈哈
    正好反了哈哈,还是要case的,对不起!
    select (select 1 from t1 where deptcode like A.deptcode+'_%') tem,deptcode from T1 A
      

  10.   

    update #t
    set deptid=null 
    where deptid in (select  distinct a.deptid
    from t a join t b on a.deptid<>b.deptid
    where CHARINDEX(a.deptcode,b.deptcode)>=1 )
      

  11.   

    大力
    你那个
    select (select 1 from t1 where deptcode like A.deptcode+'_%') tem,deptcode from T1 A
    有点问题 子查询返回的值多于一个j老师 和playyuer(心上人) 老大的可以的