Re: select during transaction**

From: Uri Dimant (urid_at_iscar.co.il)
Date: 07/05/04


Date: Mon, 5 Jul 2004 11:33:56 +0200

RM
What kind of indexes do you have ?

create an unique non-clustered index on bookid.
--1 connection
begin tran
 update books set book_desc='mathematical'
 where book_desc='psychology'
---2 connection
select * from books ---you will be waiting till the first connection to
release its lock
select bookid from books -----This time, you won't be kept waiting

See execution plan for the query.
information that you asked for could be answered by reading an index page
and does not need to read the datapage
this kind of query called as covering query

But in your case your WHERE condition contains book_id=2 therefore it will
be locked if you have an index on bookid column

"RM" <m_r1824@yahoo.co.uk> wrote in message
news:opsanmzrwshqligo@msnews.microsoft.com...
> Hi
>
> I'm working with SQL server 2000 and have
> following problrm:
>
> in query analyzer I want to update
> one row of my table called 'books' in
> a transaction
>
> my table structure and data 'book' is :
> book_id(PK) book_desc
> ---------- ------------
> 1 physics
> 2 test
> 3 psychology
> 4 culture
>
> first page(in query analyzer):
> begin transaction
> update books set book_desc='mathematical'
> where book_id=2
>
> but imagine another user from another station want
> to see all the information about books during this changing
> ,which we can try it in another page in query analyzer.
> and I tried it in 6 different types and have got
> different results as followed,why?
> is there any way to see all old information as
> the result of first case below?
>
>
>
> second page(in query analyzer):
> 1)select * from books
>
> result: query is in working....
>
> 2)select * from books where book_id=1
>
> result: OK
> book_id book_desc
> ---------- ------------
> 1 physics
>
> 3)select * from books where book_id=3
>
> result: OK
> book_id book_desc
> ---------- ------------
> 3 psychology
>
> 4)select * from books where book_id<2
>
> result: OK
> book_id book_desc
> ---------- ------------
> 1 physics
>
> 5)select * from books where book_id>2
>
> result: OK
> book_id book_desc
> ---------- ------------
> 3 psychology
> 4 culture
>
> 6)select * from books where book_id<>2
>
> result: query is in working....
>
>
>
>
>
>
> any help would be greatly thankful.
>



Relevant Pages

  • Re: Make Table Query
    ... Using that in append query (note that there is NO JOIN specified between the two ... each column in your Excel Table. ... SELECT BookID, Basement, 1 as LocValue ... > So that all books have a seperate record for each location. ...
    (microsoft.public.access.queries)
  • Re: ASP - FROM statement slows down connection to database
    ... Open your database in Access, switch to the Queries tab, create a new query ... in Design View without choosing a table, swtich to SQL View, paste the sql ... connection string rather than using an ... recordset open statements. ...
    (microsoft.public.inetserver.asp.db)
  • Re: Update checking
    ... My thought was to use a simple query with a "username" param ... concurrency exceptions happen if the data you queried has ... > was and basically let the user work in a similar offline mode. ... Where does connection pooling come ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: MS Access looks for .mdb rather than Progress schema
    ... # Same query previously worked in Progress 8.x using SQL89. ... This entry allows you to keep your existing code written with the ODBC ... BTW, if you put all of the connect information into the connect string, ... I also tried putting the whole thing in the connection string: ...
    (microsoft.public.access.modulesdaovba)
  • Re: abstraction of table relationships
    ... > the relationships between tables to make queries shorter. ... He gave the example of Books and Authors. ... > be better if one could query all books by a given author ... > done with natural join in mind. ...
    (comp.databases.theory)