Wrox Programmer Forums
|
BOOK: Beginning SQL Server 2005 Programming ISBN: 978-0-7645-8433-6
This is the forum to discuss the Wrox book Beginning SQL Server 2005 Programming by Robert Vieira; ISBN: 9780764584336
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning SQL Server 2005 Programming ISBN: 978-0-7645-8433-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2009, 05:14 PM
Registered User
 
Join Date: Sep 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chap 13, Page 413: UDFs

I replicated the dbo.AveragePrice/dbo.PriceDifference Functions as follows:

USE pubs
CREATEFUNCTION dbo.AveragePrice()
RETURNSmoney
WITH
SCHEMABINDING
AS
BEGIN
RETURN(SELECTAVG(Price)FROM dbo.Titles)
END
GO
CREATEFUNCTION dbo.PriceDifference()
RETURNmoney
AS
BEGIN
RETURN @Price-dbo.AveragePrice()
END

But when I try to run the sample query:

SELECT Title,
Price,
dbo.AveragePrice()AS Average,
dbo.PriceDifference ASDifference
FROM Titles
WHEREType='popular_comp'

I get an Error Message:

Msg 4121, Level 16, State 1, Line 1
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.AveragePrice", or the name is ambiguous.

What I am doing wrong, somebody?
 
Old January 18th, 2009, 03:24 PM
Registered User
 
Join Date: Sep 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I seen the error: I did not copy the code correctly.

----------
This p2p Forum is DEAD! No responses to question!!! The Publisher should do something about it please.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 19 Page 957 Lostincode BOOK: Ivor Horton's Beginning Visual C++ 2005 1 March 22nd, 2007 05:08 PM
Chap 13 PAGE 514,515 ninjamonk BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 October 13th, 2006 09:07 AM
Chap 3 , page 50 MacSr BOOK: Beginning VB.NET Databases 1 January 23rd, 2006 08:53 PM
Chap 13 ExampleServlet granola911 JSP Basics 0 October 20th, 2003 03:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.