Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
snufse
Constraint Violating Yak Guru
469 Posts |
Posted - 2008-06-03 : 13:03:02
|
I have a sql line that selects records:select * from prodstatistics order by shift_started desc I do not need to read the entire table and want to limit the read to the first 500 records. How would I embedd that in my current statement?Thank you. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-06-03 : 13:07:05
|
| SELECT TOP 500 *FROM prodstatistics ORDER BY shift_started DESCTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
snufse
Constraint Violating Yak Guru
469 Posts |
Posted - 2008-06-03 : 16:06:42
|
| Thank you, it worked... |
 |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2008-06-03 : 21:23:15
|
| If you are interested in taking sections of your data you can use this.select Row_Number() over (Order by Shift_Started desc) as RowID, * into #tmpfrom prodstatistics Select * from #tmp a where a.RowID between 1 and 500Select * from #tmp a where a.RowID between 501 and 1000Select * from #tmp a where a.RowID between 1001 and 1500etc |
 |
|
|
|
|
|