alter trigger tri_TC on t_c for INSERT,delete as begin set XACT_ABORT ON declare @INSERTCOUNT int; declare @DELETECOUNT int; declare @UPDATECOUNT int; set @INSERTCOUNT = (select COUNT(*) from inserted); set @DELETECOUNT = (select COUNT(*) from deleted); set @UPDATECOUNT = () if(@INSERTCOUNT > 0) begin insert into t_c2 select * from inserted; end else if(@DELETECOUNT > 0) begin delete t_c2 where exists(select temp.cid from deleted temp where temp.cid=t_c2.cid); end end
alter trigger tri_TC_Update on t_c
for update
as
begin
declare @delcount int;
set @delcount = (select count(*) from deleted);
if(@delcount > 0)
begin
begin transaction triUpdate --定义事务
declare @cname varchar(100);
select @cname = cname from inserted; --保存更新后的内容
update t_c2 set cname = @cname where cid = (select cid from deleted); --更新
if (@@error <> 0)
begin
rollback transaction triUpdate; --事务回滚
end
else
begin
commit transaction triUpdate; --事务提交
end
end
end
if(exists(select name from sysobjects s where s.name='pro_fun' and s.type='p')) drop procedure pro_fun go create procedure pro_fun as select * from table go exec pro_fun
declare @qybh varchar(10) declare cur cursor for select distinct qybh from PJ_EnterpriseInput open cur fetch next from cur into @qybh while @@fetch_status = 0 begin print(@qybh) fetch next from cur into @qybh end close cur deallocate cur
alter view CreateView as select qybh from CreateView go
alter function funName(@str1 varchar(10),@str2 varchar(10))
returns varchar(10)
as
begin
declare @returnStr varchar(10)
set @returnStr = 'false'
if(@str1 > @str2)
set @returnStr = 'true'
return @returnStr
end
select dbo.funName(... , ...)
declare @qybhTable table (id varchar(32),qybh varchar(30)) insert into @qybhTable select id,qybh from PJ_EnterpriseInput select * from @qybhTable
select sum(case when z.watchName='注册监理工程师' then 1 else 0 end), sum(case when z.watchName='xinza' then 1 else 0 end), sum(case when z.watchName='监理员' then 1 else 0 end) from zu_corjl z right join zu_corjltemp t on t.corID=z.corID
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有