表结构如下
CREATE TABLE [dbo].[car] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[BillID] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[userID] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[ProductName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[number] [decimal](10, 0) NULL ,
[SinglePrice] [decimal](18, 0) NULL ,
[TotalPrice] AS ([number] * [SinglePrice]) ,
[OrderDate] [datetime] NULL ,
[PayFlat] [int] NULL 
) ON [PRIMARY]
CREATE TABLE [dbo].[car_temp] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[userID] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[ProductName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[number] [decimal](10, 0) NULL ,
[SinglePrice] [decimal](18, 0) NULL ,
[TotalPrice] AS ([number] * [SinglePrice]) ,
[OrderDate] [datetime] NULL 
) ON [PRIMARY]其中car表比car_temp多了两例[BillID] [PayFlat],其它的一样
如何将表car_temp数据移到另一个表car

解决方案 »

  1.   


    INSERT INTO car select [id] ,'',[userID],[ProductName],[number],[SinglePrice], [TotalPrice],[OrderDate],0 from car_temp
      

  2.   

    insert into car([id],[BillID],[userID] , [ProductName],[number], 
    [SinglePrice],[OrderDate] , [PayFlat] )
    select [id],[userID],[userID] , [ProductName],[number], 
    [SinglePrice],[OrderDate] , NULL from car_temp
      

  3.   

    insert into car(字段1,字段2。)
    select 字段1,字段2。 from car_temp
      

  4.   

    insert [dbo].[car]([userID],
                      [ProductName], 
                      [number],
                      [SinglePrice],
                      [OrderDate]) 
    select [userID],
                      [ProductName], 
                      [number],
                      [SinglePrice],
                      [OrderDate]
    from   [dbo].[car_temp]