第一张表  ShopCart 表CartID int 主键,
GoodsID int,
Quantity int,
UserID int,
TotalPrice float第二张表 BuyInfo 表
BuyID int 主键,
GoodsID int,
Quantity int,
TotalPrice float,
OrderID int要将第一张表的一条记录插入到第二张表中  //主键自增(貌似不用插)本人真的不会,伤脑筋   
求教了  QQ:317401317

解决方案 »

  1.   

    insert into  BuyInfo(GoodsID,Quantity,TotalPrice)
    select GoodsID,Quantity,TotalPrice from ShopCart
      

  2.   

    insert into BuyInfo (GoodsID , 
    Quantity , 
    TotalPrice , 
    OrderID ) select 
    GoodsID , 
    Quantity , 
    UserID , 
    TotalPrice from ShopCart 
      

  3.   

    set SET IDENTITY_INSERT buyinfo on 
    insert buyinfo(buyid,GoodsID,Quantity,OrderID,TotalPrice)
    select * from ShopCart
    set SET IDENTITY_INSERT buyinfo off
      

  4.   

    INSERT BuyInfo 
    (GoodsID ,Quantity,OrderID ,otalPrice )
    SELECT GoodsID ,Quantity ,UserID ,TotalPrice ) FROM ShopCart WHERE ..
      

  5.   

    set SET IDENTITY_INSERT buyinfo on 
    insert buyinfo(BuyID,GoodsID,Quantity,OrderID,TotalPrice)
    select CartID,GoodsID,Quantity,OrderID,TotalPrice 
    from ShopCart
    set SET IDENTITY_INSERT buyinfo off