My understanding is that, in a MS SQL Server Management Studio window, after doing a "begin transaction" and then making some changes like add data to a table , you can only query that table and those changes from the same window until you do a "commit transaction".
Is there any way to do a query from another source prior to doing the "commit transaction"?
Specific to my current goal and to add some context. I do some SQL queries from Excel Power Query. I'd really like to be able do do these queries prior to the "commit transaction" so that I can do some analysis and figure out if I should be doing a rollback instead of a commit.
Best Answer
Yes, it's possible if you change the transaction isolation level for the session (that's what you call "window" in SSMS) that queries modified data. Often this is not such a great idea, as you might get some unexpected results. Consider the side effects carefully. I have no idea if it's possible to change the transacion isolation level in the Excel Power Query.
For example, the following set of queries would insert some data and display the update correctly even without commit/rollback.
Meanwhile, the second session executes a select that doesn't seem to do anything:
Create a third session and alter its isolation level: