Monday, March 26, 2012

How to use user defined function in stored procedure?

Hello friends,
I want to use my user defined function in a stored procedure.
I have used it like ,
select statement where id = dbo.getid(1,1,'abc')
//dbo.getid is a user defined function.
procedure is created successfully but when i run it by exec procedurename parameter
I get error that says
"Cannot find either column "dbo" or the user-defined function or aggregate "dbo.getid", or the name is ambiguous."

Can any body help me?
Rgds,
Kiran.

Hi,

guess you created the function not with the owner / schema (depending on which version you are working with) "dbo". So try to find the schema / owner with

SELECT * FROM INFORMATION_SCHEMA.Routines
Where Routine_Name = ''getid"

One column is SPECIFIC_SCHEMA, lookfor this and try to rewrite the statement in your proc. The fact that the non-existence of the function isn′t throwing an error is called "deferred name resolution".

http://msdn.microsoft.com/library/en-us/createdb/cm_8_des_07_5wa6.asp

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||Thanks for the solution
Rgds,
Kiran Suthar

No comments:

Post a Comment