Pரதீப்
Pரதீப்

Reputation: 93754

Calling scalar function through Exec

I have created a scalar function

CREATE FUNCTION dbo.Dumm()
returns INT
AS
  BEGIN
      DECLARE @a INT
      SELECT @a = 1
      RETURN @a
  END

Now I am calling the scalar function through Exec not through select

EXEC dbo.Dumm 

It did not return 1. It just says

Command(s) completed successfully.

Whats happening internally. Is there any meaning for it ?

Upvotes: 0

Views: 2501

Answers (1)

Joe Taras
Joe Taras

Reputation: 15389

Try this:

DECLARE @ret int;
EXEC @ret = dbo.Dumm 

and then show the result querying your variable @ret as follow:

SELECT @ret

Tell me if it's OK

Upvotes: 4

Related Questions