How to enable automatic transaction scoping on SQL Server Management Studio? - tsql

I'm used to work with tools like Toad or PL/Sql Developer for Oracle and every SQL statement I run on the query window runs automatically under a trasaction scope. So, if my SQL statement is not correct, or even if I miss something on the SQL script I can rollback only by clicking on a button at the UI. If everything worked as expected, I can click on another button for commiting the current transaction.
On those tools I mentioned, I don't need to write SQL statements for begin, commit or rollback a transaction. Every SQL statement has an implicit transaction associated with.
Is there a way to achieve the same functionality on SQL Server Management Studio 2008?

You'd have to set "Implict Transactions" in tools..options..query execution
To enable COMMIT or ROLLBACK, I can only think of using the CTRL+number shortcuts

Related

Automatic database update with DbUp in multi application environment

I have multiple desktop apps that can run DbUp at startup. And how to handle this situation if couple apps run DbUp at the same time?
I have to have automatic solution for that because there are plenty clients and DB update cannot be run by the DBA. It must be work automatically after the app update (actually it is also automatic).
DB update could be executed during the application update. But also it doesn't solve the concurrency problem because app update also could happen simultaneously. DbUp doesn't have any lock mechanism instead of transaction. I've added some lock table and added script to update value in it at every update script begin. But there is a problem that script continue to run after other DbUp instance finishes the job.
It would work if the lock table update run before schemaversion reading. Then after the lock table release it would read schemaversion table and could then realize that there are all updates already executed.
Application .Net Core based and DB is MySql.

Postgres pgcli: How to review transaction queries before commit?

I'm using pgcli to execute a transaction on a postgresql database. I've come to the point where I'm almost ready to commit, I now want to review the queries I've ran. Is there a way to do this, either with pgcli or psql? I've looked at the postgresql docs and pgcli docs but haven't found anything.
I've seen dbeaver records queries made during a transaction, but I'd like to see if it's possible using commandline tools.
The best solution I have so far is to hit the up arrow and page through recent commands until I see my last BEGIN query. After, I would page back down until I reach the most recent query.

SQL Stored procedure stuck strange issue

I have a stored procedure which deployed on different clients.
This stored procedure is working fine all the time.
Sometimes while using the web application, the
page which calls this stored procedure keeps loading and will return a time out exception FOR ALL USERS.
To fix this issue, right click on stored procedure, modify, then F5 to execute same procedure (with no change on procedure),
Back to web part and refresh, everything will work fine.
It seems that the not very optimal plan is stored to the cache. When you re-create procedure (F5), you clear the cache. When this situation happens again, try to get execution plan and check what params are stored in the cache. Additionally you can add WITH RECOMPILE option, that would probably slow down performance a bit, but you will not have such situations

ADF activity is in progress state for a longer period of time

I have a daily schedule ADF pipeline that consist of couple of activities. The first activity basically invokes a stored procedure that takes less than 2 second to run on DB side but the activity is running continuously(In Progress state for longer period of time). Initially I thought it was due to the blocking on SQL server side. But the problem is there is NO SQL SERVER hit from ADF side. The strange thing is running on Dev environment but getting blocked in QA.
Here is the RunId for the same:
Thanks!
Sometimes you can invoke a stored procedure with a copy activity, changing the SqlReaderQuery property to something like "exec 'sp_name'". I explained this here: Execute storedProcedure from azure datafactory
Your problem looks like the integration runtime cannot reach the database, try opening the integration runtime, and connecting to the database from the diagnostic tab. Once you make it work there, make sure the linked service is configured with those credentials.
Hope this helped!

The implementation of Transaction with out msdtc in the design pattern

The transaction has implemented as shows below.When executed it says there is no begin transaction and the whole package exe has been roll backed.
How to get this work with out changing the structure
After the execution
For this transaction setup to work with Microsoft DBMS - you have to specify RetainSameConnection=true in Connection Manager properties.
More details on this approach with screenshots.