foreveryoung
Programmer
Please can you help me with a function I am trying to create in TSQL.
I want the results of different queries returned depending on the parameter I pass to the function.
The query seems to break at the "if" statement so I guess my syntax is wrong.
I am sure its an easy solution but havent been able to resolve.
Thanks
David
I want the results of different queries returned depending on the parameter I pass to the function.
Code:
ALTER function [mercerd].[FN_Endoscopy_E01_QuarterlyCensus] (@lineid char(3))
returns table
as
return
(
IF @LINEID = '123'
BEGIN
select * FROM TABLE1
END
ELSE
BEGIN
SELECT * FROM TABLE2
END
END
)
The query seems to break at the "if" statement so I guess my syntax is wrong.
I am sure its an easy solution but havent been able to resolve.
Thanks
David