<table-valued function> is not a recognized built-in function name
It's a table-valued function. So you probably meant:
SELECT p.DOCTORFISTNAME, p.DOCTORLASTNAME, t.FirstName, t.Middle, t.LastName
FROM dbo.[PracticeandPhysician] AS p
CROSS APPLY dbo.fnParseName(p.DOCTORFIRSTNAME + ' ' + p.DOCTORLASTNAME);
Note that you can't say:
SELECT dbo.TableValueFunction('foo');
Any more than you could say:
SELECT dbo.Table;
--or
SELECT dbo.View;
You can, however, say:
SELECT * FROM dbo.fnParseName('foo bar');
--or
SELECT FirstName, Middle, LastName FROM dbo.fnParseName('foo bar');
(Not that I have validated that your function does what you think, or does so efficiently.)
Please always use the dbo.
prefix as others have suggested.
UDFs/Functions need to be prefixed with the schema name (most likely "dbo"). Change the call to
SELECT
dbo.fnParseName(DOCTORFIRSTNAME + ' ' + DOCTORLASTNAME)
FROM
[PracticeandPhysician]
The problem you have is similar to what I encountered too. Scalar function and Table inline functions are quite different in terms of implementation. See below for the diiferent
Create function udfCountry
(
@CountryName varchar(50)
)
returns varchar(2)
as
BEGIN
Declare @CountryID varchar(2),
@Result varchar(2)
Select @CountryID = Country from
dbo.GeoIPCountryNames where CountryName = @CountryName
set @Result = isNull(@CountryID, 'NA')
if @Result = 'NA'
set @Result = 'SD'
return @Result
End
//Implementation
select dbo.[udfCountry]('Nigeria')
// sample result
NG
// Inline table function sample
Create FUNCTION ConditionEvaluation
(
@CountrySearch varchar(50)
)
returns @CountryTable table
(
Country varchar(2),
CountryName varchar(50)
)
as
Begin
Insert into @CountryTable(Country, CountryName)
Select Country, CountryName from GeoIPCountryNames
where Country like '%'+@CountrySearch+'%'
return
end
//Implementation sample
Declare @CountrySearch varchar(50)
set @CountrySearch='a'
select * from ConditionEvaluation(@CountrySearch)
the parttern of implementating scalar is quite different inline table. I hope this helps
You always have to prefix SQL function calls with the schema name dbo.
or the schema name for that function (dbo is the default schema).
SELECT dbo.fnParseName(--etc