Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to call a userdefined function within a stored

Author  Topic 

smithani
Starting Member

42 Posts

Posted - 2007-08-27 : 16:47:14
Hello All,
How do i call a user defined function from within a stored procedure,
I have created a simple function which takes firstname and lastname as parameters and returns the concatenated name string.
That part works.


declare @fullname varchar(400)
@fullName=getFullName(@firstname,@lastname)


As always thanks for all your input

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-27 : 16:48:20
set @fullName = getFullName(@firstname,@lastname)
select @fullName=getFullName(@firstname,@lastname)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-27 : 16:52:38
You might have to prefix your function with dbo or rightful owner.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

smithani
Starting Member

42 Posts

Posted - 2007-08-27 : 17:00:16
I should have checked the post first, yeh. Yes you are right, found out the hard way.
Got an error saying "not a built in function".
When I prefixed with dbo, it worked

set @fullName = dbo.getFullName(@firstname,@lastname)
select @fullName=dbo.getFullName(@firstname,@lastname)

Thanks Peso for all your help

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-27 : 17:11:56
Only scalar functions need prefix, table functions do not.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -