I want to select a stored proc to execute based on user input. Something like -
EXEC
CASE @InputParam
WHEN 'XML' THEN GetXMLData @ID, 'y'
WHEN 'TABLE' THEN GetTableData @ID, 'y'
END
Can this be done with CASE
or should I consider using the If
construct?
You want to use the IF
construct here:
IF @InputParam = 'XML'
EXEC GetXMLData @ID, 'y'
IF @InputParam = 'TABLE'
EXEC GetTableData @ID, 'y'