如果我在SQL服務器執行下面的SQL語句的查詢2008年,它完美的作品,但是當SQL Server 2000中執行同一語句,這是行不通的:SQL 2000 is'not執行,2008年可以執行
聲明:在SQL Server 2000
select top 1
[k].[FixbiUnitPrice]
from (
select top (select COUNT(*)
from [dbo].[mnrFnBI_Fixed]('4E591E71-33BD-4ECC-8703-771BE8A76817') f)
[FixbiUnitPrice],
BDate,
biNumber
From [dbo].[mnrFnBI_Fixed]('4E591E71-33BD-4ECC-8703-771BE8A76817') f
where f.BAccCustID != 0x0
order by f.BDate desc,f.BNumber desc,f.biNumber desc
) [k]
輸出:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '('.
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'FixbiUnitPrice'.
這有什麼錯的語法爲SQL Server 2000
它不起作用。頂部x表達式不能是動態的。 –
感謝您的快速重播,所以我如何解決上述語句與SQL 2000工作?!可以做什麼其他方式?! –
我不確定SQL Server 2000的問題,但試着將'TOP'計算成變量,然後在查詢中使用變量。 'DECLARE @n INT SET @n =(SELECT COUNT(*)FROM ...)... SELECT TOP(@n)...' –