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 |
|
vladimir_grigoro
Yak Posting Veteran
62 Posts |
Posted - 2005-01-05 : 08:51:22
|
| Hi All,I have the following problem, whish I had to solve. I want to select dynamically "top" from particular result e.g.:SELECT TOP 10 * FROM TABLE_A but I want to make the number "10" as a variable....something like:SELECT TOP @X * FROM TABLE_AIs there anybody who knows how to receive such result?Thanks in advance!The Rebel |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-05 : 08:56:22
|
| set rowcount @XSELECT * FROM TABLE_Aset rowcount 0==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
vladimir_grigoro
Yak Posting Veteran
62 Posts |
Posted - 2005-01-05 : 09:02:33
|
Thanks a lot!!! You were so fast:-)Tnx one more time...quote: Originally posted by nr set rowcount @XSELECT * FROM TABLE_Aset rowcount 0==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.
The Rebel |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-01-06 : 01:00:04
|
other solution isdeclare @X numericset @x=1print @xexec('SELECT top '+@X+' * FROM table')Madhivanan |
 |
|
|
|
|
|