做一个维修管理软件。维修接受/出库记录的数据管理界面(有添加/删除/编辑等功能)。
在用户录入的时候,可能会一次性输入10条数据。所以我想用临时表。先把这10条数据写入临时表。(这个过程允许用户修改)。最后确认了总的把这10条数据写到真正的数据表中去。首先用存储过程创建临时表,代码如下:
if exists (select * from sysobjects where id = object_id(N'[temptable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[temptable]
select * into temptable from MaintainInfor where InforID='SYSTEM'
select * from temptable其中MaintainInfor是真正表,temptable是临时表。
但是MaintainInfor表中有一个字段inforDT的数据类型是datetime,默认数值用SQL函数getdate(),用系统时间做为记录时间(这样比较准确,不会因为客户端电脑被改时间而出错!)。但是问题就这么出来了,用设计查看temptable的inforDT没有getdate函数啊。
请问我该如何解决这个问题呢????

解决方案 »

  1.   

    select *,getdate() into temptable from MaintainInfor where InforID='SYSTEM'
      

  2.   

    服务器: 消息 8155,级别 16,状态 1,行 1
    没有为第 10 列(属于 'temptable')指定列。
      

  3.   

    select *,getdate() into #temptable from MaintainInfor where InforID='SYSTEM'
      

  4.   

    我把原表中除了inforDT字段的字段都写出来。SELECT InforID,MobileType,SN,MalCode,whereIs,Analyst,State,Number,GETDATE() AS InforDT into #temptable from MaintainInfor where InforID='SYSTEM'这样可以查询执行成功。