Dovberman
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,QuoteD ate
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,QuoteD ate
FROM StockHist
Can this be done?
Thanks,
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,QuoteD
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,QuoteD
FROM StockHist
Can this be done?
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
ASKER