-- Example about IF sentence using AdventureWork Database
DECLARE @SeleccionQuery INT = 1;
IF(@SeleccionQuery = 1 OR @SeleccionQuery = 3) AND NOT @SeleccionQuery IS NULL
BEGIN
SELECT
p.ProductID,
p.Name,
p.Color
FROM Production.Product AS p
WHERE p.Color = 'Red'
ORDER BY p.Name
END
ELSE
BEGIN
SELECT
p.ProductID,
p.Name,
p.Color
FROM Production.Product AS p
WHERE p.Color = 'Black'
ORDER BY
p.Name
END
No hay comentarios:
Publicar un comentario