饿虎岗资源网 Design By www.oxmxm.com
sql不常用函数总结以及事务,增加,删除触发器
distinct 删除重复行
declare @x 申明一个变量
convert(varchar(20),tscore.tenglish) 类型转换
cast(xx as varchar(10)) 类型转换
www.jb51.net
======================================================
情况
case
when xxx then xx
when xxxx then xxxxx
else
end
=======================================================
while xxx
begin
xxxxxx
end
www.jb51.net
事务
===================================================
begin tran
declare @sum int = 0
update bank set balance=balance-1000 where cid='0001'
set @sum=@sum+@@error
update bank set balance=balance + 1000 where cid='0002'
set @sum=@sum+@@error
if @sum<>0
begin
rollback
print '回滚!'
end
else
begin
--提交事务
commit tran
print '提交了!'
end
===================================================
begin tran www.jb51.net
begin try
declare @sum int = 0
update bank set balance=balance-900 where cid='0001'
set @sum=@sum+@@error
update bank set balance=balance + 900 where cid='0002'
set @sum=@sum+@@error
commit
end try
begin catch
rollback
end catch
=====================================================
declare @halfCount int= ceiling(@count/2.0) 向上
增加时触发器
=========================================
create trigger tri_TblClass_insert_after
on TblClass after insert
as
begin
declare @id int
declare @name varchar(50)
declare @desc varchar(50)
select @id=tclassId,@name=tclassname,@desc=tclassdesc from inserted
print @id
print @name
print @desc
end www.jb51.net
=========================================
删除时触发器
create trigger tri_TblClass_delete_after
on TblClass instead of delete
as
begin
insert into TblClassBak
select * from deleted
end
========================================
作者 xhccom
distinct 删除重复行
declare @x 申明一个变量
convert(varchar(20),tscore.tenglish) 类型转换
cast(xx as varchar(10)) 类型转换
www.jb51.net
======================================================
情况
case
when xxx then xx
when xxxx then xxxxx
else
end
=======================================================
while xxx
begin
xxxxxx
end
www.jb51.net
事务
===================================================
begin tran
declare @sum int = 0
update bank set balance=balance-1000 where cid='0001'
set @sum=@sum+@@error
update bank set balance=balance + 1000 where cid='0002'
set @sum=@sum+@@error
if @sum<>0
begin
rollback
print '回滚!'
end
else
begin
--提交事务
commit tran
print '提交了!'
end
===================================================
begin tran www.jb51.net
begin try
declare @sum int = 0
update bank set balance=balance-900 where cid='0001'
set @sum=@sum+@@error
update bank set balance=balance + 900 where cid='0002'
set @sum=@sum+@@error
commit
end try
begin catch
rollback
end catch
=====================================================
declare @halfCount int= ceiling(@count/2.0) 向上
增加时触发器
=========================================
create trigger tri_TblClass_insert_after
on TblClass after insert
as
begin
declare @id int
declare @name varchar(50)
declare @desc varchar(50)
select @id=tclassId,@name=tclassname,@desc=tclassdesc from inserted
print @id
print @name
print @desc
end www.jb51.net
=========================================
删除时触发器
create trigger tri_TblClass_delete_after
on TblClass instead of delete
as
begin
insert into TblClassBak
select * from deleted
end
========================================
作者 xhccom
饿虎岗资源网 Design By www.oxmxm.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
饿虎岗资源网 Design By www.oxmxm.com
暂无评论...
更新日志
2024年11月15日
2024年11月15日
- 欧倩怡.2001-Cindy(EP)【华星】【WAV+CUE】
- P1X3L《P1X3L》[FLAC/分轨][791.28MB]
- 茵达INDAHKUS《茵 the Blue》[320K/MP3][33.49MB]
- 茵达INDAHKUS《茵 the Blue》[FLAC/分轨][147.57MB]
- 老虎鱼AnneClarkwithUllavanDaelenJustinCiuche-Borderland-HiRes-Files24bit88.2kHz
- 江玲2004-百合盛开2CD[歌林][WAV+CUE]
- 孙露《怕什么孤单3CD》深圳音像[WAV分轨]
- s14全球总决赛目前是什么结果 s14全球总决赛赛程结果图一览
- s2TPA夺冠五人名单都有谁 tpa战队s2夺冠队员名单一览
- s13wbg战队成员都有谁 wbg战队s13成员名单一览
- 网友热议《幻兽帕鲁》停售、赔千万日元:那也赚麻了 不亏
- 这谁顶得住 《最终幻想7:重生》尤菲3D作品穿上终极芙蕾娜衣服
- 外媒称PS5pro违背承诺:《蜘蛛侠2》根本没法4K60帧
- 群星.2007-中文十大金曲30周年纪念专辑【RTHK】【WAV+CUE】
- 杨林.1989-留一点爱来爱自己【综一唱片】【WAV+CUE】