2012年2月26日星期日

first n records

How can I select only the first n records from a table ?

Regards,

Ciornei Mihai

Simple:

select top n * from table

e.g.

select top 100 * from suppliers

or

select top 3000 address, contact from suppliers

Although this doesn't seem to work in SQL 2005 Compact Edition.

|||

OK I know top n dosen't work.

Also set rowcount = n dosen't work.

So ... what would be the solution?

|||Sorry, you didn't actually mention you were using CE, but I should have guessed. I'm not sure you can do it in CE, if I'm wrong, someone please let me know!|||Get all the records and only use the first x - or wait for SQL CE 3.5, which will support TOP.

没有评论:

发表评论