日期:2014-05-16 浏览次数:20521 次
drop table ##t
select top 100 * into ##t from busiorder where year(createtime)=2013 and companyid=@companyid and [status]<5
select top 1 * from ##t order By NewID()//这里是可以查询到数据
INSERT INTO busiorder(orderno, busiorderno, subsysid, classid, goodsid, goodscount,customid
,[description],[type],goodsoutreason,serviceday,refusereason,phonenum,[address],recordpoint,
creator,createtime,updater,lastmodify,paymode,contacttime,callbackflag,processorid,companyid,
syncflag,accountflag,needbill,billtitle,billtype,customname,[status],proccontent,totalprice,
porderno,priority,areano,callid,billno,resultperiod,resultdesc,resultservice,resultname,sbegindate,
senddate,ticketcallback,callbackcontent,ticketstatus,assigner,allotmode,billdate
) SELECT top 1 @maxorderno+1, @maxbusiorderno+1, subsysid, classid, goodsid, goodscount,customid
,[description],[type],goodsoutreason,@xdate,refusereason,phonenum,[address],recordpoint,
creator,@xdate,updater,@xdate,paymode,contacttime,callbackflag,processorid,companyid,
syncflag,accountflag,needbill,billtitle,billtype,customname,[status],proccontent,totalprice,
porderno,priority,areano,callid,billno,resultperiod,resultdesc,resultservice,resultname,@xdate,
@xdate,ticketcallback,callbackcontent,ticketstatus,assigner,allotmode,billdate FROM ##t order By NewID()