Farinha
Farinha

Reputation: 18091

How to inspect SQL Server database during a transaction?

I'm trying to debug part of an application where a number of actions on the database are taking place inside the same transaction, with the later steps depending on the ones completed before. It would be useful to be able to take a look at what's going on in the database, to make sure each step is being completed correctly.

Is there a way to take a look at what's in the database while a transaction is running?

Upvotes: 1

Views: 272

Answers (4)

Branko Dimitrijevic
Branko Dimitrijevic

Reputation: 52107

An extension of the WITH (NOLOCK) idea expressed in other answers... You could simply:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

Which would then allow you to "snoop" into data that has not yet been committed by the transaction being debugged. This is very useful if you need to call stored procedures or functions, which cannot be directly subjected to WITH (NOLOCK).

Upvotes: 0

RubbleFord
RubbleFord

Reputation: 7636

SELECT * FROM dbo.Table WITH (NOLOCK)

will do what your looking for, just be careful of phantom reads.

Upvotes: 2

Moo-Juice
Moo-Juice

Reputation: 38825

If you mean that you want to look at table data (an assumption on my behalf) you can always use the the WITH (NOLOCK) constraint on the table - but I am not certain you'll get anything that has been modified in your transaction.

Upvotes: 2

Internet Engineer
Internet Engineer

Reputation: 2534

If you want to know which SQL statements are being executed use SQL Server Profiler

Upvotes: 0

Related Questions