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.

 All Forums
 Site Related Forums
 Article Discussion
 Your article on..........

Author  Topic 

KnooKie
Aged Yak Warrior

623 Posts

Posted - 2001-06-14 : 11:53:42
Dynamic SQL or How do I SELECT TOP @var records?

Link http://www.sqlteam.com/item.asp?ItemID=233


I was wondering if there was an error in this article and in particular the piece of code below:

declare @vSQL varchar(1000), @numrows int
select @numrows = 25
select @v1 = 'select top ' + convert(varchar, @numrows) + ' * from MyTable Order by DateColumn'
Execute (@v1)

Should the declare variable be called @v1

Just thought i'd mention it






Edited by - KnooKie on 06/14/2001 11:56:18
   

- Advertisement -