• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1301
  • 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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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