September 19, 2007 at 11:24 am
I am facing a serious problem in SQL server 2000.
I have a table called testtable
When I ruuning a query like in one editor like
Query1:
begin transaction
insert into dbo.testtable values(5,'trante', 'testfor tran')
And in second window I am running a query like
Query 2:
select * from dbo.testtable
I will not get any result till i do commit or rollback of first query.
I am not able to understand this issue
Can anybody help me immediatly. I need help urgently.....
September 19, 2007 at 11:28 am
This is expected behavior. let's say your transaction that modifies the data adds temporary information. E.g in case of accounts that a person has 1000000 USD if this is rolled back, this information should not have been visible in any of the other transactions. I suggest you read about transactions.
If it is acceptable for you to look at data that is "dirty"
, i.e. bay not be committed, have a look at isolation levels, and you will be able to set this.
http://msdn2.microsoft.com/en-us/library/ms173763.aspx
Regards,
Andras
September 19, 2007 at 11:30 am
http://msdn2.microsoft.com/en-us/library/ms190612.aspx
is a good starting point about learning the basics about transactions.
Regards,
Andras
September 19, 2007 at 2:35 pm
I have to read committed data.
But not able to read the committed data also
what I do for that
September 19, 2007 at 2:40 pm
Try it this way:
Query1: begin transaction insert into dbo.testtable values(5,'trante', 'testfor tran') if @@error = 0 commit else rollback
September 20, 2007 at 12:57 am
I hope I not made my question very clear.
My question is:
In my table already I have some data like 1,'test','niraj test'
Now the situation is:
User1 from one system run the query and not committed or rollback the transaction:
begin transaction
insert into dbo.testtable values(5,'trante', 'testfor tran')
Then on other system user2 running the query
Select * from testtable
The problem is User2 is not able to see the committed data.
My question is why this happening as user2 just want to read the committed data.
Since in my application this situation occurs often.
Please help me what I should do for this.
September 21, 2007 at 11:45 am
I suspect that you are used to the same behavior that exists in Oracle for transactions. SQL Server blocks READS. Oracle does not.
Now you are posting to the 2005 admin forum. If you have 2005, there is a way to setup SQL Server to operate the same way Oracle Does.
ALTER DATABASE <database name>
SET READ_COMMITTED_SNAPSHOT ON
WITH <termination>;
ALTER DATABASE <database name>
SET ALLOW_SNAPSHOT_ISOLATION ON;
September 21, 2007 at 3:24 pm
Actually I was facing the problem in sql server 2000. I found there is no way in SQL server 2000; except the dirty read.
Any how my company planning to upgrade to SQL server 2005. In SQL server 2005 I can use isolation level SNAPSHOT or SET READ_COMMITTED_SNAPSHOT ON.
I already found the solution .
Thanks
October 3, 2007 at 7:07 am
I fount the solution.
Actually I was looking for the Transaction which behaves like ORACLE.
Like While Read Pessimetic
abd while Update Opptimistic
This is available in SQL server 2005 by introducing two new isolation: Read committed isolation with row version, and Snapshot Isolation.
Thanks to one who helped me.:D
October 3, 2007 at 11:26 pm
The other solution you might try would be to look at the locking for the INSERT statement.
if this was restricted to a ROW level lock (rather than page or table) then you should be able to read the previously committed data with any locking level.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply