• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1312
  • Last Modified:

How to execute a SQL Scalar Valued Function from SQL Management Studion query window

I have created a scalar valued function which returns a single value and I execute it in a sproc. It works fine but I want to test it from a Query Window but I can't see how to do that.
When I type in "exec MyDatabase.dbo.fn_MyFunction" all I get in the results window is
"Command(s) completed successfully."
I would like to see the reults of the function. Thanks for any help.
0
AkAlan
Asked:
AkAlan
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
If your function returned a VARCHAR(200) you would do something like:
DECLARE @Test VARCHAR(200)
EXEC @Test = MyDatabase.dbo.fn_MyFunction

PRINT @Test

Open in new window

0
 
tigin44Commented:
you should call it like

select MyDatabase.dbo.fn_MyFunction
0
 
AkAlanAuthor Commented:
I tried the other persons answer but I got an error
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now