JohnDTampaBay
Programmer
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.
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] [rainbow] [rainbow]](/data/assets/smilies/rainbow.gif)
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
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 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] [rainbow] [rainbow]](/data/assets/smilies/rainbow.gif)
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)