I use SQL Server 2005 and I create function.Below I mention the Function that I created.

CREATE FUNCTION dbo.udf_GetCountryID(@Name varchar(50))
RETURNS VARCHAR(1000) AS

BEGIN
Declare @Description varchar(4000)
select @Description = coalesce(@Description + ',' , '' ) +  countryCode 
FROM dbo.Test_Table where CommonName='Japan'

Return @Description
END

After creating function I use below SQL statement

select dbo.udf_GetCountryID(Distinct(F.CommonName))CountryName from dbo.Test_Table F

but I got the Error message.Below I mention the error message also
Msg 208, Level 16, State 101, Line 1
Invalid object name 'dbo.udf_GetCountryID'.


Once I create the function its comes under scalar-valued function.I am using sql server 2005.Please help me

Thanks
Tank50

Hi,

Could you give a try with following code change;

SELECT DISTINCT(dbo.udf_GetCountryID(F.CommonName)) AS CountryName 
FROM dbo.Test_Table F

Good luck.

Thanks MeSampath.Its works.Thank you

Tank50

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.