Try this:
declare @top varchar;
set @top = 2;
exec('select top ' + @top + ' * from books;');
HTH,
Sam
> -----Original Message-----
> From: Richard Meredith-Hardy [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, December 29, 2002 3:34 PM
> To: CF-Talk
> Subject: top clause in a SP
>
>
> Happy new year (nearly)
>
> I would like to be able to pass the TOP n value into a SP,
> but can't get it to work.
>
> you would think the following would work, but whatever data
> type I cast @xx as, it doesn't like it:
>
> DECLARE @xx int
> SET @xx = 150
>
> SELECT TOP @xx field1 Etc....
>
> anyone any ideas?
>
> (this is SQL Server 2000 / CF5)
>
> --
> Regards;
>
> Richard Meredith-Hardy
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm