Solved

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

Posted on 2011-02-26
3
1,228 Views
Last Modified: 2012-05-11
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
Comment
Question by:AkAlan
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
Comment Utility
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
 
LVL 26

Expert Comment

by:tigin44
Comment Utility
you should call it like

select MyDatabase.dbo.fn_MyFunction
0
 
LVL 6

Author Closing Comment

by:AkAlan
Comment Utility
I tried the other persons answer but I got an error
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now