if exists(select * from archive.dbo.开发商出证个人办理按揭的)
 
   drop table Archive.dbo.开发商出证个人办理按揭的select *into 开发商出证个人办理按揭的 from archive.dbo.v_house where houseid in(
 select housetxm from housedb.dbo.fchb where dz in (select dz from housedb.dbo.a_ajb where (isnull(hthm,'') = '' or hthm is null) and zhxbz<>1 and ISNULL(qsr,'')<>'' and ISNULL(dyr,'')<>'')
) and len(obligee)>7 if exists(select * from archive.dbo.按揭各人未证地址)
 
   drop table Archive.dbo.按揭各人未证地址 
select * into 按揭各人未证地址 from housedb.dbo.a_ajb where (isnull(hthm,'') = '' or hthm is null) and zhxbz<>1 and ISNULL(qsr,'')<>'' and ISNULL(dyr,'')<>''update a set a.fid=b.id,a.status='已办按揭*',bookid=null,a.obligee=b.qsr,a.cardid=b.qsrsfzh,a.djzh=null,a.archiveNo=b.archiveID from 开发商出证个人办理按揭的 a,按揭各人未证地址 b where a.houseRepose=b.dz insert into v_house 
select * from 开发商出证个人办理按揭的

解决方案 »

  1.   


    if exists(select * from archive.dbo.开发商出证个人办理按揭的)
      
      drop table Archive.dbo.开发商出证个人办理按揭的select *into 开发商出证个人办理按揭的 from archive.dbo.v_house where houseid in(
     select housetxm from housedb.dbo.fchb where dz in (select dz from housedb.dbo.a_ajb where (isnull(hthm,'') = '' or hthm is null) and zhxbz<>1 and ISNULL(qsr,'')<>'' and ISNULL(dyr,'')<>'')
    ) and len(obligee)>7  if exists(select * from archive.dbo.按揭各人未证地址)
      
      drop table Archive.dbo.按揭各人未证地址 
    select * into 按揭各人未证地址 from housedb.dbo.a_ajb where (isnull(hthm,'') = '' or hthm is null) and zhxbz<>1 and ISNULL(qsr,'')<>'' and ISNULL(dyr,'')<>''update a set a.fid=b.id,a.status='已办按揭*',bookid=null,a.obligee=b.qsr,a.cardid=b.qsrsfzh,a.djzh=null,a.archiveNo=b.archiveID from 开发商出证个人办理按揭的 a,按揭各人未证地址 b where a.houseRepose=b.dz  insert into v_house  
    select * from 开发商出证个人办理按揭的
      

  2.   

    建议把
    select *
    改一下,比如:select a,b,c,.....
      

  3.   

    数据量不是很多,所以改* 暂时不用,但现在手动执行可以成功,但它自己执行就报错
    消息
    已以用户 MJFGJDATA\sqlcluster 的身份执行。 数据库中已存在名为 '开发商出证个人办理按揭的' 的对象。 [SQLSTATE 42S01] (错误 2714).  该步骤失败。
      

  4.   

    LZ写插入语句应该多注意下!if exists(select * from archive.dbo.开发商出证个人办理按揭的)
      
      drop table Archive.dbo.开发商出证个人办理按揭的insert into 开发商出证个人办理按揭的 select * from archive.dbo.v_house where houseid in(
     select housetxm from housedb.dbo.fchb where dz in (select dz from housedb.dbo.a_ajb where (isnull(hthm,'') = '' or hthm is null) and zhxbz<>1 and ISNULL(qsr,'')<>'' and ISNULL(dyr,'')<>'')
    ) and len(obligee)>7  if exists(select * from archive.dbo.按揭各人未证地址)
      
      drop table Archive.dbo.按揭各人未证地址 
    insert  into 按揭各人未证地址 select * from housedb.dbo.a_ajb where (isnull(hthm,'') = '' or hthm is null) and zhxbz<>1 and ISNULL(qsr,'')<>'' and ISNULL(dyr,'')<>''update a set a.fid=b.id,a.status='已办按揭*',bookid=null,a.obligee=b.qsr,a.cardid=b.qsrsfzh,a.djzh=null,a.archiveNo=b.archiveID from 开发商出证个人办理按揭的 a,按揭各人未证地址 b where a.houseRepose=b.dz  insert into v_house  
    select * from 开发商出证个人办理按揭的
      

  5.   


    if exists(select * from archive.dbo.开发商出证个人办理按揭的)
      drop table Archive.dbo.开发商出证个人办理按揭的if exists(select * from archive.dbo.按揭各人未证地址)
      drop table Archive.dbo.按揭各人未证地址select * into 开发商出证个人办理按揭的 from archive.dbo.v_house
    where houseid in(
        select housetxm from housedb.dbo.fchb
        where dz in (select dz from housedb.dbo.a_ajb
                     where (isnull(hthm,'') = '' or hthm is null)
                       and zhxbz<>1 and ISNULL(qsr,'')<>''
                       and ISNULL(dyr,'')<>'')
              ) and len(obligee)>7       )  --少括号!
     
    select * into 按揭各人未证地址 from housedb.dbo.a_ajb
    where (isnull(hthm,'') = '' or hthm is null)
          and zhxbz<>1 and ISNULL(qsr,'')<>''
          and ISNULL(dyr,'')<>''update a 
    set a.fid=b.id,a.status='已办按揭*',bookid=null,a.obligee=b.qsr,a.cardid=b.qsrsfzh,a.djzh=null,a.archiveNo=b.archiveID
    from 开发商出证个人办理按揭的 a,按揭各人未证地址 b
    where a.houseRepose=b.dz  insert into v_house  
    select * from 开发商出证个人办理按揭的
      

  6.   

    判断表是否存在的方法有问题
    应该是use archive
    if exists(select * from sysobjects where name= '开发商出证个人办理按揭的')
      

  7.   


    查询分析器里可以执行并不代表具体的调用不会出问题,还是得看外部的业务,比如一个分页存储过程,如果在其中开始时判断表是否存在,然后删除表或者直接执行SQL语句,在查询分析里肯定不会出错,但在程序调用的时候会出现问题,说该表已经创建,或者该表在系统目录中不存在,无法删除等等问题!是因为调用比较频繁,会出现逻辑判断错误!