set xact_abort on 设置事务回滚的当为ON时,如果你存储中的某个地方出了问题,整个事务中的语句都会回滚为OFF时,只回滚错误的地方 例子 : ALTER proc [dbo].[BuChongZhaiQuan_SQl] as begin set xact_abort on begin transaction --if exists(select 1 from InvestorApply where RedeemDate=(select ShouldPayDate=max(Shou…
需求: MSSQL,列出服務實例中全部數據庫的例如以下信息: 數據庫ID.數據庫名.創建日期.數據文件類型.數據文件大小.數據庫總大小.文件所在路徑. 寫法(後面的百分比為所花時間占比): -- 连接子查询 (47%) WITH cte_TotalSize AS ( SELECT database_id ,CAST(SUM(size) AS FLOAT)/128 AS [TotalSize(MB)] FROM sys.master_files GROUP BY database_id ) SEL…
选课系统,当同意学号选课数量超过则回滚事务,符合条件则正常插入数据 --开始一个事务处理Begin Tran T1 --执行插入操作insert into Courselist values('20100021','01');insert into Courselist values('20100021','02');insert into Courselist values('20100021','03');insert into Courselist values('20100021','0…
--处理file与folder中的order -- 声明变量 DECLARE @fileid AS INT, @folderid AS INT, @order AS INT, @oldFolderId AS INT, @orderCursor AS INT; -- 声明游标 DECLARE C_FILE CURSOR FAST_FORWARD FOR SELECT Id,FolderID,[ORDER] FROM FILES where [ORDER]=0 ORDER BY FolderId,N…