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 |
|
clip
Starting Member
5 Posts |
Posted - 2005-01-04 : 11:25:53
|
| How can I select N number of records from a table |
|
|
Hippi
Yak Posting Veteran
63 Posts |
Posted - 2005-01-04 : 11:30:07
|
quote: Originally posted by clip How can I select N number of records from a table
Yeap,set rowcount Nselect * from tableor u can use dynamic queryHTH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-01-06 : 06:47:30
|
Try thisdeclare @X numericset @x=10print @xexec('SELECT top '+@X+' * FROM table')Madhivanan |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-06 : 08:09:27
|
if you use ser rowcount don't forget to put it back to 0 after you statement:set rowcount Nselect * from tableset rowcount 0if you don't everything will be done for just the top N records.Go with the flow & have fun! Else fight the flow |
 |
|
|
clip
Starting Member
5 Posts |
Posted - 2005-01-06 : 09:11:45
|
| thanx a lot to all. The answer works very fine somehow.cu soon... |
 |
|
|
|
|
|