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 |
|
raysefo
Constraint Violating Yak Guru
260 Posts |
Posted - 2010-12-22 : 10:16:47
|
| Hi,I m querying DB according to some inputs from user. There is a field, Number of Records if user enters lets say 20, i would like to retrieve 20 records from the query.Is this possible?Thanks in advance.Best Regards |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-12-22 : 10:25:56
|
| use the TOP clause with a variabledeclare @row intset @row = 20select top (@row) * from yourTableJimEveryday I learn something that somebody else already knew |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-12-23 : 03:04:15
|
| Also add a Order by clauseMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|