Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to check transaction if commited or not

Author  Topic 

bo0tl3ss
Starting Member

20 Posts

Posted - 2011-08-10 : 05:13:24
hi, just like to know is theres function to check if on the current insert is commited or not. thanks

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-08-10 : 07:07:48
Would examining @@TRANCOUNT meet your needs? http://msdn.microsoft.com/en-us/library/ms187967.aspx
Go to Top of Page

bo0tl3ss
Starting Member

20 Posts

Posted - 2011-08-10 : 21:56:56
thanks for the information bro, but still it does not call my trigger after last insert.


IF (@@TRANCOUNT = 0)
BEGIN
EXEC master ..xp_cmdshell 'C:\trigger.bat'
END
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-08-11 : 09:30:27
You will need to debug to see why that is happening. use SELECT @@TRANCOUNT to see if there are open transactions. If there are none, check if xp_cmdshell is enabled, and if it is, whether it is failing within the bat file etc.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-08-11 : 12:21:40
You are kind of in control of transactions.

If you start one, you should finish (commit) it, so you will know that it's done. Certainly you can check the Tran Count or you could use XACT_STATE(), but is there some reason, out side of an error condition, that you will not know if you committed you own transaction?

Here is a link about XACT_STATE:
http://msdn.microsoft.com/en-us/library/ms189797(v=sql.90).aspx
Go to Top of Page
   

- Advertisement -