| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
小女子做了一个存储过程,是用来备份数据的.代码部分如下: select * into #test from chat_record insert into chat_record_history select * from #test delete chat_record where exists (select content from #test where chat_record.content=#test.content) 将表chat_record中的数据先放到一临时表#test中.然后在将临时表#test中的数据放到历史表chat_record_history 中,最后删除chat_record表和临时表#test相同的记录. 现在在insert into chat_record_history select * from #test这个步骤出错后,也就是没有将记录插入到历史表中,但是它又删掉了,原来表的数据.现在想用begin trans.请问怎么用呀!!!我自己试了几次还是有问题.请大家帮忙 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
事务处理begin transtraction和比较经典的存储过程
最新推荐文章于 2025-02-17 08:44:38 发布