Ich habe ein Problem mit meinem Code: P offensichtlich richtig ?! Wie auch immer ... hier ist, was es ist ... Ich möchte einen STORED PROC haben, der 3 Argumente (@cat, @cutPrice, @option) hat und mehrere Ergebnisse zurückgibt, die einen ähnlichen Typ wie @cat haben, und einen Preis, der ist < oder> @cutPrice abhängig vom @option-Schlüsselwort "über" oder "unter". Das Problem ist, wenn ich diese ...Filterung durch Argumente in Stored Proc
EXEC spBookByPrice
@cat = 'business', @cutPrice = 0.00, @option = 'above'
... ich bekomme keine Ergebnisse, aber @option = '' zeigt alle Preise. Auf jeden Fall ist hier mein Code ....
ALTER PROC spBookByPrice
@cat varchar(12), @cutPrice money, @option varchar(5)
AS
BEGIN
SELECT
title AS 'Title:',
type AS 'Category:',
price AS 'Price:',
CASE
WHEN price >= @cutPrice THEN 'above'
WHEN price < @cutPrice THEN 'below'
--ELSE NULL
END AS 'Option:'
FROM dbo.titles
WHERE 'Option:' LIKE '%' + @option + '%'
GROUP BY type, title, price
HAVING type LIKE '%' + @cat + '%'
END
Sie Gurwinder Danke, genau das was ich fehlte !!!! –
Ich musste nur den [Option:] Alias mit der vollständigen CASE-Anweisung ersetzen –
@Kyle Genau .. :) – GurV