表结构如下
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
INSERT INTO car select [id] ,'',[userID],[ProductName],[number],[SinglePrice], [TotalPrice],[OrderDate],0 from car_temp
[SinglePrice],[OrderDate] , [PayFlat] )
select [id],[userID],[userID] , [ProductName],[number],
[SinglePrice],[OrderDate] , NULL from car_temp
select 字段1,字段2。 from car_temp
[ProductName],
[number],
[SinglePrice],
[OrderDate])
select [userID],
[ProductName],
[number],
[SinglePrice],
[OrderDate]
from [dbo].[car_temp]