SQL スカラー関数で 1 つの変数を使用して 2 つの値を返す方法はありますか
ALTER FUNCTION [report].[fGetKPI] (@metricName AS VARCHAR(50))
RETURNS SMALLINT
AS
BEGIN
DECLARE
@kipId AS SMALLINT,
@metricId as SMALLINT;
SELECT TOP 1 @kipId = [KPI_Id], @metricId = [MetricId] FROM report.[KPIDetails] WHERE [MetricName] = @metricName;
IF (@kipId IS NULL OR @metricId IS NULL)
DECLARE @Error AS INT = dbo.fThrowError('No key found for the component "' + @metricName + '"');
RETURN (select @kipId,@metricId);
END