我收到错误:
{"语法不正确' @ 0'。"}
当我将@ 0更改为整数(即100)时,我收到错误:
{"语法不正确' *'。"}
我不确定发生了什么。我所读到的CTE问题不再是petapoco的问题。 有什么想法吗?
Using db = New Database("cs")
oHistoricalTicker = db.SingleOrDefault(Of MyTicker)(";WITH CTE AS
(
SELECT TOP @0 (*) FROM Ticker WHERE ProductId=@1
ORDER BY ID DESC
) SELECT TOP (1) * FROM CTE ORDER BY ID ASC", iHistoricalTicks, TicketSymbol)
End Using
答案 0 :(得分:1)
SQL应该是:
;WITH CTE AS
(
SELECT TOP (@0) * FROM Ticker WHERE ProductId=@1
ORDER BY ID DESC) SELECT TOP (1) * FROM CTE ORDER BY ID ASC