I am using Oracle's SQL Developer to execute queries against my SQL Server 2008 database as I simply can't work with SSMS as long as it doesn't support Ctrl + Return to execute statements...
Anyway, statements in SQL Server seem to be autocommit even when using Oracle SQL Developer. Is it possible to change this on a permanent basis? BEGIN TRANSACTION
is not a solution for me.
2 Answers 2
SQL Server uses autocommit mode by default. This cannot be changed permanently.
There are two ways implicit transactions (non-autocommit) can be turned on:
At the server level such that new sessions use it by default, using
sp_configure 'user options'
-- this may or may not work depending on how SQL Developer was implemented.For a session, using
SET IMPLICIT_TRANSACTIONS ON
.
-
1@Daniel: "For dblib network library connections, controls whether a transaction is started implicitly when a statement is executed. The IMPLICIT_TRANSACTIONS setting has no effect on ODBC or OLEDB connections." (emphasis mine)Jon Seigel– Jon Seigel2012年07月25日 12:58:18 +00:00Commented Jul 25, 2012 at 12:58
In SQL Developer you can try this technique:
/*sqldev:stmt*/begin transaction;
INSERT ...
update ...
/*sqldev:stmt*/rollback;
See: http://stackoverflow.com/questions/17826779/disable-autocommit-in-sql-developer-when-using-mysql
-
1The OP clearly says: '
BEGIN TRANSACTION
is not a solution for me.'András Váczi– András Váczi2015年11月03日 16:01:12 +00:00Commented Nov 3, 2015 at 16:01 -
Well, actually, SQL Developer is blocking everything starting with
BEGIN
. So,BEGIN TRANSACTION
itself is not a solution for anybody. The magic comment does the trick. I was looking for the same in SQL Developer as the OP; I think this solution sould be mentioned here. It wasn't straiforward to find it.LiborStefek– LiborStefek2015年11月03日 18:17:36 +00:00Commented Nov 3, 2015 at 18:17 -
SQL Developer is written in Java and typicaly uses JDBC Drivers for connection to databases. Answer given by Jon is not working for Daniel nor for me.LiborStefek– LiborStefek2015年11月03日 18:33:00 +00:00Commented Nov 3, 2015 at 18:33