Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using "select TOP" with parameter

Status
Not open for further replies.

DRH192

Programmer
Apr 25, 2005
96
GB
Is it possible to replace the value in the SQL with a parameter when working with select top queries. I want to beable to determin the number at run time and do not want to have to change the SQL to do this.

I know I could do it programatically but I dont want to start doing it this way if I can use a parameter in the select query.

Many thanks
 
Don't believe so. Parameters can be used to supply values to a query but not operators or predicates ... and TOP n is a predicate. You will probably have to modify the SQL in code.

[small]On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. (Charles Babbage)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top