0

Is it the same as executing a stored procedure?

1
  • I'll talk for the one who gave you -1 and left... Can you provide more information ? The same on what points ? Commented Aug 1, 2012 at 16:31

1 Answer 1

2

No, a SQL function must be referenced with its schema name and must be part of the appropriate part of a SELECT statement. For scalar-valued functions this is something like SELECT dbo.MyLookupFunction(12). For a table-valued function, SELECT columnA, columnB, columnC FROM dbo.MyTableLookupFunction(12). See CREATE FUNCTION (Transact-SQL) and Executing User-Defined Functions (Database Engine) for more information about functions in SQL.

The java code is, of course, the same as for any other query.

Sign up to request clarification or add additional context in comments.

4 Comments

When I try SELECT dbo.MyLookupFunction(12), i get the following exception, com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 1.
12 is just an example, if you're using parameters with your java code try replacing the 12 with ? and execute that. Java's classes for this expect place holders to match the parameters. Parameters in SQL can be expressed in 2 ways, unnamed by using a ?, and named using @parametername.
I'm using the ? character, but it's still not working. Is SELECT dbo.MyLookupFunction(?,?) valid?
Add the code you're using to your question. That should be valid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.