1

Select Top N using a stored procedure parameter

by Jon 13. September 2010 17:22

If you want to allow your users to select the top N rows to reduce the strain your database, but you want to be able pass N in as a parameter as a stored procedure just wrap the Parameter in () and it wont complain.

Alter Procedure cp_StoredProcedureName

@TopN as integer

as

select top (@TopN) Field1,Field2 from TablleName

where Field3 = "Something"

Tags:

SQL

Comments (1) -

Nathan
Nathan United Kingdom
14/09/2010 06:21:28 #

Now that's worth knowing!

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


Powered by BlogEngine.NET 2.0.0.36
Original Design by Laptop Geek, Adapted by onesoft, and finally some tiny tweaks by JonAlb