Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Your article on..........
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Aged Yak Warrior

United Kingdom
623 Posts

Posted - 06/14/2001 :  11:53:42  Show Profile  Visit KnooKie's Homepage  Reply with Quote
Dynamic SQL or How do I SELECT TOP @var records?


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

Chief SQLTeam Crack Dealer

4149 Posts

Posted - 06/15/2001 :  01:46:47  Show Profile  Visit graz's Homepage  Reply with Quote
Boy I wish one of the 6091 people that read the article before you would have caught that. I really wish I would have caught it!

At least it's fixed now. Thanks.


Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2019 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000