Link to home
Start Free TrialLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

TSql Syntax, H0w to set a parameter

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,
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dovberman

ASKER

Thank you.
Thank you.