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 2008 Forums
 Transact-SQL (2008)
 Strange union query failure

Author  Topic 

GustiX
Starting Member

28 Posts

Posted - 2012-07-14 : 20:13:52
Hi

I have a stored procedure that has a cursor with a union query statement, something like:

declare DEMO cursor for
select col1 from table1
union
select col2 from table2
fetch next ... and so on

It appears that sometimes when the procedure is run
I only get half of the expected records (only from table2)
Is it possible if there is a deadlock (or something blocking
the select statement from table1) that a union query would only
give the results from the bottom half of a union query?

I would think that if something is blocking the top half
of the union query that it would just fail... ???

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-14 : 22:51:27
hmm...not something i've seen so far. try this variant and see if you can reproduce same error

declare DEMO cursor for
select col
from
(
select col1 as col from table1
union
select col2 from table2
)t
fetch next ...


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -