Solved

function is not a recognized built-in function name.

Posted on 2014-10-13
6
250 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
email the result out from a T-SQL queries 29 62
ASP.NET 5 Templates 2 65
T-SQL: Nested CASE Statements 4 24
Sql query 107 25
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

910 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

19 Experts available now in Live!

Get 1:1 Help Now