TSql Syntax, H0w to set a parameter

Dovberman
Dovberman used Ask the Experts™
on
I need to substitute a parameter value into sql syntax as follows:

ALTER PROCEDURE [dbo].[usp_getUTestArray]
      -- Add the parameters for the stored procedure here
      @SymbolID int,
      @HistRange smallint
      
AS
BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;

    -- Insert statements for procedure here
      SELECT TOP 18 SymbolID,ClosePrice,QuoteDate
      FROM StockHist
      WHERE
      SymbolID = @SymbolID
      AND QuoteDate <= (SELECT TOP 1 QuoteDate
            FROM DownLoadDates
            WHERE MarketID=2
            ORDER BY QuoteDate DESC )
      ORDER BY QuoteDate DESC

@HistRange is 18.

I need the equivalent of

SELECT TOP @HistRange  SymbolID,ClosePrice,QuoteDate
      FROM StockHist


Can this be done?

Thanks,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Consultant
Top Expert 2009
Commented:
SELECT TOP (@HistRange ) SymbolID,ClosePrice,QuoteDate
      FROM StockHist

Author

Commented:
Thank you.

Author

Commented:
Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial