我使用下面的查询,但说Incorrect syntax near if
如何解决这个问题?
CREATE FUNCTION getCustomerAllReseller
(
@code BIGINT
)
RETURNS TABLE AS
RETURN (
WITH Directories AS
(
IF (@code < 0)
SELECT code FROM CustomerAll WHERE code = @code
ELSE
SELECT code FROM Customer WHERE code = @code
)
SELECT * FROM Directories
)