请问高手们能不能在SQL的触发器中删除表呢??

ufyjh 2001-12-12 07:19:08
...全文
80 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ufyjh 2001-12-12
  • 打赏
  • 举报
回复
create trigger maniform_inst
on DispatchList
for insert
as
select CASE datalength(rtrim(ltrim(str(max(cvouchid)+1))))
when 1 then 'R0000000000'+rtrim(ltrim(str(max(cvouchid+1))))
when 2 then 'R000000000'+rtrim(ltrim(str(max(cvouchid+1))))
when 3 then 'R00000000'+rtrim(ltrim(str(max(cvouchid+1))))
when 4 then 'R0000000'+rtrim(ltrim(str(max(cvouchid+1))))
when 5 then 'R000000'+rtrim(ltrim(str(max(cvouchid+1))))
when 6 then 'R00000'+rtrim(ltrim(str(max(cvouchid+1))))
when 7 then 'R0000'+rtrim(ltrim(str(max(cvouchid+1))))
when 8 then 'R000'+rtrim(ltrim(str(max(cvouchid+1))))
when 9 then 'R00'+rtrim(ltrim(str(max(cvouchid+1))))
End as cLink,
CASE datalength(rtrim(ltrim(str(max(cvouchid)+1))))
when 1 then '000000000'+rtrim(ltrim(str(max(cvouchid+1))))
when 2 then '00000000'+rtrim(ltrim(str(max(cvouchid+1))))
when 3 then '0000000'+rtrim(ltrim(str(max(cvouchid+1))))
when 4 then '000000'+rtrim(ltrim(str(max(cvouchid+1))))
when 5 then '00000'+rtrim(ltrim(str(max(cvouchid+1))))
when 6 then '0000'+rtrim(ltrim(str(max(cvouchid+1))))
when 7 then '000'+rtrim(ltrim(str(max(cvouchid+1))))
when 8 then '00'+rtrim(ltrim(str(max(cvouchid+1))))
when 9 then '0'+rtrim(ltrim(str(max(cvouchid+1))))
End as cvouchid,max(cVouchType) as cVouchtype,max(cexch_name) as cexch_name,max(cFlag) as cFlag
into kk2 from Ap_vouch
Select b.*,a.dDate as DVouchdate,a.Ccuscode as CdwCode,a.cDepCode as cDeptcode,a.cPersoncode as cPerson,a.isum-a.cdefine7 as
iRAmount into kk3 from SA_DispatchListEX a,kk2 b where a.kflag<>'A'
insert into ap_vouch(cLink,cVouchid,cVouchtype,cExch_name,cFlag,dVouchdate,cdwcode,cdeptcode,cperson,iramount) select * from kk3
drop table kk2 //如何删除表(临时表,如果不删除的话下一次就会出错,你有其他方法吗??
drop table kk3 //如何删除表
go


ufyjh 2001-12-12
  • 打赏
  • 举报
回复
旺财兄,表已经存在,不过就是不能drop table tablename??
taber 2001-12-12
  • 打赏
  • 举报
回复

可以,不过先要在触发器中判断这个表是否存在……

5,939

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧