Solved

function is not a recognized built-in function name.

Posted on 2014-10-13
6
227 Views
Last Modified: 2014-10-13
I am getting:

Msg 195, Level 15, State 10, Line 1
'fnHasOrders' is not a recognized built-in function name.

(using SQLEXPRESS12 apparently iif() is acceptable to use)

After creating
Create FUNCTION dbo.fnHasOrders
(
 -- the parameters for the function here
 @CustomerID   int
)
RETURNS  varchar(20)
AS
BEGIN

declare @response  varchar (20)

Select @response = iif(isnull(o.OrderID,0)=0,'','<-- has orders') 
From tblCustomers c left join tblOrders o 
on o.CustomerID = c.CustomerID Where c.CustomerID=@CustomerID

 -- Return the result of the function
 RETURN @response

End

Open in new window


FYI: This function shows up under Functions/Scalar-value function folder at SSMS



Select CustomerID, fnHasOrders(CustomerID) from tblCustomers
0
Comment
Question by:Mike Eghtebas
  • 3
  • 3
6 Comments
 
LVL 48

Accepted Solution

by:
PortletPaul earned 500 total points
ID: 40379133
add
        dbo.

select CustomerID, dbo.fnHasOrders(CustomerID) from tblCustomers
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40379146
My favorite expert!

Thanks for the hint. There is a followup question.

Jack Smith            <-- has orders
Robert Nissan           <-- has orders

I want to line up <-- has orders portions in:

       SQL.ExecQuery("SELECT CustomerID, FirstName + ' ' + LastName + '     ' +" &
                     " dbo.fnHasOrders (CustomerID) as CustName From tblCustomers")


by having variable number of blank spaces instead of just '     ' above.

brb
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40379151
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 48

Expert Comment

by:PortletPaul
ID: 40379211
:) you are too kind, but thank you!

Cheers, Paul
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 40379213
btw: you can also use the SPACE() function

 SQL.ExecQuery("SELECT CustomerID, substring(FirstName + ' ' + LastName + space(50) ,1,50) +" &
                     " dbo.fnHasOrders (CustomerID) as CustName From tblCustomers")
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40379226
Appreciate the tip.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now