Solved

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

Posted on 2011-02-26
3
1,276 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34989470
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
ID: 34989472
you should call it like

select MyDatabase.dbo.fn_MyFunction
0
 
LVL 6

Author Closing Comment

by:AkAlan
ID: 34989478
I tried the other persons answer but I got an error
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

717 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