你按提示做不就行了,要不就不要插入自增字段的值

解决方案 »

  1.   

    declare @CmdNo int, @CarNo varchar(200) 
        declare c1 cursor for select CarNo from tmp_UserCommand 
        open c1  
        fetch next from c1 into @CarNo 
        begin transaction 
        while @@Fetch_Status=0 
          begin
          
    set identity_insert cmd_UserCommand on
          insert cmd_UserCommand (写上字段列表)
    select * from tmp_UserCommand  where CarNo=@CarNo 
          select @CmdNo=@@identity 
           insert cmd_UserCommandDetail (CmdNo,COrderID,BarCode,amount,AreaCode) 
             select @CmdNo,COrderID,BarCode,amount,AreaCode 
                from tmp_UserCommandDetail where CarNo=@CarNo 
            update sys_Car set UsableFlag=1 where carno=@CarNo 
            fetch next from c1 into @CarNo 
          end 
        close c1 DEALLOCATE c1 
        update cmd_CustomerGoodsDetail set CommandFlag=1 from tmp_UserCommandDetail a 
          where cmd_CustomerGoodsDetail.COrderID=a.COrderID and 
          cmd_CustomerGoodsDetail.BarCode=a.BarCode 
         commit transaction;
      

  2.   

    还是不可以,,执行起来还是有错误。
      

  3.   

    表中存在标识列的时候,对其执行插入操作,要指明具体的列.
    因为标识列ID是不允许写的.