Calling scalar function through Exec

Asked at 2017-01-11 11:03:25Z
  • 5 Subscribers
  • 114 Views
0

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 ?


2 answers in total

4
Joe Taras Posted at 2017-01-11 11:11:26Z

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

-1
Mansoor Posted at 2017-01-11 11:05:52Z
Use SELECT Clause :

SELECT [dbo].[Dumm]

Answer this questsion