Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Derived table and Could not find database error

Status
Not open for further replies.

JohnDTampaBay

Programmer
Jul 12, 2002
986
US
I have the query below (in blue) that will act as a derived table in a larger query. If I run it, I get the expected record set. However, when I use it as a derived table (by wrapping it in the red text), I get the error below.

Code:
Server: Msg 913, Level 16, State 8, Line 1
Could not find database ID 102. Database may not be activated yet or may be in transition.
SELECT * FROM (
SELECT x.Num
, s.RevenuesChg
, s.NetIncomeChg
, s.NetOpCashFlow
, s.NetOpCashFlowChg
, s.ROE
FROM RPR.dbo.StockData s
INNER JOIN (SELECT 8 AS Num
UNION SELECT 16
UNION SELECT 32
UNION SELECT 64) x
ON RPR.dbo.fnCheckBitwise(s.Period, x.Num) = 1
WHERE s.CoCode = '$INX'
AND s.RPRVersion = 55
) f

What's my problem? What am I missing here?

--Angel [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
perhaps you need to explicity name the columns you want?



Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top