SQL Compact select top 1

Tomas Tintera picture Tomas Tintera · Sep 26, 2008 · Viewed 22.9k times · Source

While porting an application from SQL 2005 to SQL Server Compact Edition, I found that I need to port this command:

SELECT TOP 1 Id FROM tblJob WHERE Holder_Id IS NULL

But SQL Server Compact Edition doesn't support the TOP keyword. How can I port this command?

Answer

Robinb picture Robinb · Sep 26, 2008
SELECT TOP(1) Id 
FROM tblJob 
WHERE Holder_Id IS NULL

Need the brackets as far as I know.

reference: http://technet.microsoft.com/en-us/library/bb686896.aspx

addition: likewise, only for version 3.5 onwards