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 |
|
adlo
Posting Yak Master
108 Posts |
Posted - 2004-08-31 : 13:15:07
|
| I want to pass a parameter @num to a stored procedure to return the top @num results backSelect top @num .....from TableIt doesn't allow it and says incorrect syntax.Is this possible? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-31 : 13:18:38
|
| two ways to do it:declare @v1 intset @v1 = 25set rowcount @v1select * from MyTable Order by DateColumnset rowcount 0declare @vSQL varchar(1000), @numrows intselect @numrows = 25select @vSQL = 'select top ' + convert(varchar, @numrows) + ' * from MyTable Order by DateColumn'Execute (@vSQL)Go with the flow & have fun! Else fight the flow :) |
 |
|
|
adlo
Posting Yak Master
108 Posts |
Posted - 2004-08-31 : 13:24:04
|
| Thanks |
 |
|
|
|
|
|