Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling UDFs from store procedure...

Status
Not open for further replies.

Kris11

Programmer
Jan 31, 2003
278
US
How do I call a SQL Server User Defined function from a SQL Server Store Procedure? I have a function that returns a datetime and I want to call this in a store procedure to get the returned date time.

Thnx

Kris
 
In your SP:

Code:
DECLARE @dt datetime

SET @dt = myfunc()

--James
 
From Books Online:
When calling a scalar user-defined function, you must supply at least a two-part name:

SELECT *, MyUser.MyScalarFunction()
FROM MyTable

 
Thanks Guys,

Yes, after JamesLean's suggestion when I tried calling function, it gave me a compilation error that "xxx function is not a recognized name", so I just tried adding

DECLARE @dt datetime

SELECT @dt = dbo.xxx( 1, 1 )

and it worked. Anyway thanks a lot for the help

Kris
 
Hey James, trust me I learned this one the hard way. I guess those are the lessons that stick with you, huh?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top