E
E
egorggegor2020-07-15 14:01:36
SQL
egorggegor, 2020-07-15 14:01:36

How to run a function and put its result into a variable?

CREATE FUNCTION GetConfigID @CL ID INT
RETURNS INT AS
BEGIN
  DECLARE @SConfigIdID INT
  SET @SConfigIdID = (SELECT ConC. ID FROM tblContract CN
    INNER JOIN tblClient CL ON CN.CLIENT_ID = CL.ID INNER JOIN tblCar CR ON CN.CAR_ID = CR.ID
    INNER JOIN tblConfigCar ConC ON CR.CONFIG_MODEL_ID = ConC. ID WHERE Cl.ID = @CL_ID)

RETURN @ConfigldID
END
GO

Is there a function, how to run it, so that the result is placed in a variable?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2020-07-15
@egorggegor

DECLARE @G INT
SELECT @G = dbo.GetConfigID( 1 )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question