Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 The multi-part identifier "dbo.StartYear" could no

Author  Topic 

gavinjb
Starting Member

34 Posts

Posted - 2007-09-20 : 05:31:23
Hi,

I am trying to run a simple function I have created with :

Select dbo.StartYear

but get the following error


Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "dbo.StartYear" could not be bound.

The Code for the function is



set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Gavin Blackford
-- Create date: 15-March-2007
-- Description: Returns Start AutoCost Year
-- =============================================
ALTER FUNCTION [dbo].[StartYear] ()
RETURNS varchar(4)
AS
BEGIN
-- Return the current autocost startyear
RETURN convert(varchar,(select prefvalue from prefs where prefname = 'AutoCostYear'))

END


Can anyone help.

Thanks,


Gavin,

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-09-20 : 06:06:25
Select dbo.StartYear()

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-20 : 06:38:47
Two more points to note

1 If you dont specify column length, by default 30 would be taken for varchar column
2 You need to make sure the query inside that function always returns single value only

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -