-
-
Save j717273419/ab9dbda684f558a470084f9817aa9de5 to your computer and use it in GitHub Desktop.
sql server 事务示例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--如果出错,全回滚整个事务 | |
SET XACT_ABORT off | |
begin tran | |
INSERT INTO [dbo].[SsoLog] (Sl_Login_Time) VALUES (GETDATE()) | |
INSERT INTO [dbo].[SsoLog] (Sl_Login_Time) VALUES (222) | |
INSERT INTO [dbo].[SsoLog] (Sl_Login_Time) VALUES ('key04') | |
commit tran | |
--如果出错,全回滚整个事务 | |
begin tran | |
INSERT INTO [dbo].[SsoLog] (Sl_Login_Time) VALUES (GETDATE()) | |
INSERT INTO [dbo].[SsoLog] (Sl_Login_Time) VALUES (222) | |
INSERT INTO [dbo].[SsoLog] (Sl_Login_Time) VALUES ('key04') | |
commit tran | |
roolback | |
--如果出错,全回滚整个事务 | |
begin try | |
begin tran | |
INSERT INTO [dbo].[SsoLog] (Sl_Login_Time) VALUES (GETDATE()) | |
INSERT INTO [dbo].[SsoLog] (Sl_Login_Time) VALUES (GETDATE()) | |
INSERT INTO [dbo].[SsoLog] (Sl_Login_Time) VALUES (GETDATE()) | |
INSERT INTO [dbo].[SsoLog] (Sl_Login_Time) VALUES ('key04') | |
commit tran | |
end try | |
begin catch | |
rollback | |
end catch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment