views:

1247

answers:

3

I've tried

 select top 1 * from tbl
 select top(1) * from tbl
 select * from tbl limit 1

Nothing worked.

Does SQL Server Compact Edition support getting the top x rows?

+5  A: 

Yes it does, and your second syntax should be correct. What happens when you try it?

However, the keyword was added in version 3.5, so if you are using an earlier version, then the answer is no it doesn't. Sorry.

David M
I get this:Major Error 0x80040E14, Minor Error 25501> select top(1) * from callThere was an error parsing the query. [ Token line number = 1,Token line offset = 8,Token in error = top ]
AngryHacker
Editing my post.
David M
David is absolutely right, that it's a CE 3.5 feature. At this point, though, the performance boosts, bug fixes, and feature enhancements make it absolutely necessary to upgrade. Just make sure to handle upgrading old databases in the wild!
Bob King
Ok, I just noticed that SSMS is loading version 3.1 of the Compact Edition. I can't seem to get rid of it. Uninstalling didn't really help - it's still in the SSMS. Even though I installed 3.5 SP1, SSMS still loads 3.1
AngryHacker
A: 

Docs from MSDN seems to indicate it should work.

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

Maybe post more of your script? Do you do anything else in there.

jfrobishow
AngryHacker
+1  A: 

If your SQL CE hosed VS there is a Visual Studio Magazine post that talks about how to reinstall it correctly.

It is not fun, but it does work.

Jason Short