Código SQL:
Ver originalIF EXISTS ( SELECT 1
FROM tabla1 AS a INNER joint tabla2 AS b ON a.x = b.x
INNER JOIN tabla3 AS c ON b.x = c.x)
BEGIN
SELECT a.nombre, a.dir, a.telefono, b.nombre, b.precio, b.total, b.descuento,
c.almacen, c.descripcion
FROM tabla1 AS a INNER joint tabla2 AS b ON a.x = b.x
INNER JOIN tabla3 AS c ON b.x = c.x
END
ELSE
BEGIN
IF EXISTS ( SELECT 1
FROM tabla1 AS a INNER joint tabla2 AS b ON a.x = b.x
INNER JOIN tabla3 AS c ON b.x = c.x INNER JOIN P ON p.x = a.x)
BEGIN
SELECT P.nombre, p.dir, a.telefono, b.nombre, b.precio, b.total, b.descuento,
c.almacen, c.descripcion
FROM tabla1 AS a INNER joint tabla2 AS b ON a.x = b.x
INNER JOIN tabla3 AS c ON b.x = c.x INNER JOIN P ON p.x = a.x
END
END
Con eso no ocupas toda la sentencia en el select ;)