Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How can I get data at a table

Author  Topic 

heovang1211
Starting Member

5 Posts

Posted - 2009-11-17 : 21:56:53
Now, I have 1 stored procedure 'UpdateCustomer':
.....
process something
....
begin tran updatetable
insert tblUser values('Tommy', 1)
commit tran updatetable

....
print 'inserted successfully'
continue processing something ....
.....
Next, I run this stored and after it finish command above (this stored is still running), I want to query data at tblUser to get User 'Tommy' with query string : "Select * from tblUser". But SQL always query and doesn't return the result. I just have the result after the stored 'UpdateCustomer' runs complete.
So, the question is how can I get data at table tblUser immediately while the store 'UpdateCustomer' is running.

Thank you for your help.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-11-17 : 22:18:48
why are u using explicit transaction for something like this?
Go to Top of Page

heovang1211
Starting Member

5 Posts

Posted - 2009-11-17 : 22:29:32
I use transaction to want that data really will be inserted into tblUser to I can query them while this stored is still running.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-17 : 23:13:11
Transactions do not guarantee that your data will be inserted into the table. That is not the purpose of them. The purpose of them is data integrity when you have multiple DML statements.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

heovang1211
Starting Member

5 Posts

Posted - 2009-11-18 : 03:08:27
so, how can I get data at table tblUser immediately while the store 'UpdateCustomer' is running?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-18 : 10:34:20
I'd start with changing the isolation level of the database to READ_COMMITTED_SNAPSHOT. After that nothing special needs to happen.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

heovang1211
Starting Member

5 Posts

Posted - 2009-11-18 : 20:57:46
??? I don't understand what you said, please explain, thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-18 : 21:04:40
Take a look at READ_COMMITTED_SNAPSHOT isolation level in SQL Server Books Online. It prevents reads from blocking writes by instead using snapshots and tempdb.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -