CREATE PROCEDURE [dbo].[BO_GetTickers]
	@TickerId				INT	=NULL,
	@Currency1				VARCHAR(4) = NULL,
	@Currency2				VARCHAR(4) = NULL,
	@ExchangeId				SMALLINT = NULL
AS
	SELECT t.ExchangeId, t.TickerId, t.TickerSymbol, t.Base Currency1, t.NonBase Currency2, t.Currency, t.TickerDisplayName, ISNULL(s.Decimals, 8) as Decimals
	FROM Tickers t
	LEFT JOIN Symbols s ON s.Symbol = t.NonBase
	WHERE (@TickerId IS NULL AND @ExchangeId IS NULL) OR (@TickerId = t.TickerId AND @ExchangeId IS NULL) OR 
		(ISNULL(@TickerId, TickerId) = TickerId AND @ExchangeId = ExchangeId AND @Currency1 = t.Base AND @Currency2 = t.NonBase)
GO