数据库有个表Customer,其数据是来自0.28的表UserListinsert into Customer (CustomerId,Account,FullName,Tel,Contactor)
  select CustomerId,Account,FullName,Tel,Contactor from [192.168.0.28].[OID2009].[dbo].[UserList] 
   where deleted=0 and len(Account)>8 and CustomerId not in (select CustomerId from Customer)
现在想把表UserList中的一列数据Address也增加到Customer表中,不知道SQL语句怎么写

解决方案 »

  1.   

    alter table Customer with no check add address varchar(200);
    go
    insert into Customer (CustomerId,Account,FullName,Tel,Contactor,address)
      select CustomerId,Account,FullName,Tel,Contactor,address from [192.168.0.28].[OID2009].[dbo].[UserList]
      where deleted=0 and len(Account)>8 and CustomerId not in (select CustomerId from Customer)
      

  2.   

    ?insert into Customer (CustomerId,Account,FullName,Tel,Contactor,Address) 
      select CustomerId,Account,FullName,Tel,Contactor,Address from [192.168.0.28].[OID2009].[dbo].[UserList] 
      where deleted=0 and len(Account)>8 and CustomerId not in (select CustomerId from Customer) 
      

  3.   

    ALTER TABLE Customer  ADD Address VARCHAR(2000)INSERT Customer  SELECT ............
      

  4.   

    --这样?
    说明:跨数据库之间表的拷贝(具体数据使用绝对路径) (Access可用) 
    insert into b(a, b, c) select d,e,f from b in ‘具体数据库’ where 条件 
    例子:..from b in '"&Server.MapPath(".")&"\data.mdb" &"' where.. 
      

  5.   

      ALTER TABLE 表 ADD UpdateDate datetime
    单纯增加一列语法
      

  6.   

    不是哦 我的意思是原来数据表Customer中已经有数据了,不能删除的哦
      

  7.   

    --1更改表
    alter table Customer with no check add address varchar(200);
    go
    --2更改 Customer已有数据行
    update Customer set address
    from [192.168.0.28].[OID2009].[dbo].[UserList] a 
    inner join Customer c on a.CustomerId=c.CustomerId
    --3.增加 Customer中没有的行
    insert into Customer (CustomerId,Account,FullName,Tel,Contactor) 
      select CustomerId,Account,FullName,Tel,Contactor from [192.168.0.28].[OID2009].[dbo].[UserList] 
      where deleted=0 and len(Account)>8 and CustomerId not in (select CustomerId from Customer) 
      

  8.   

    --1更改表
    alter table Customer with no check add address varchar(200);
    go
    --2更改 Customer已有数据行
    update Customer set address= a.address
    from [192.168.0.28].[OID2009].[dbo].[UserList] a 
    inner join Customer c on a.CustomerId=c.CustomerId
    --3.增加 Customer中没有的行
    insert into Customer (CustomerId,Account,FullName,Tel,Contactor) 
      select CustomerId,Account,FullName,Tel,Contactor from [192.168.0.28].[OID2009].[dbo].[UserList] 
      where deleted=0 and len(Account)>8 and CustomerId not in (select CustomerId from Customer) 
      

  9.   


    alter table Customer with nocheck add address varchar(200);
    go
     update Customer set address= ul.address
     from [192.168.0.28].[OID2009].[dbo].[UserList] ul 
     inner join Customer c on ul.CustomerId=c.CustomerId
      

  10.   


    alter table Customer with nocheck add address varchar(200); 
    go 
    update Customer set address= ul.address 
    from [192.168.0.28].[OID2009].[dbo].[UserList] ul 
    inner join Customer c on ul.CustomerId=c.CustomerId