views:

29

answers:

2

here my code-

create function dbo.emptable()
returns Table
as
return (select id, name, salary from employee)
go

select dbo.emptable()

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

while when I run
sp_helptext emptable it shows-

create function dbo.emptable()  
returns Table  
as  
return (select id, name, salary from employee) 

it means function exists in database then why it is giving such error?

+3  A: 

Is it because when you select from the function you need to say

select * from dbo.emptable() 

not

select dbo.emptable() 
kevchadders
oh yes, how could I skip that....thanks
nectar
+1  A: 

select * from dbo.emptable()

It's a table, after all...

Rob Farley