开发者

how to Invoke User-Defined Functions That Return a Table Data Type

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()  
retu开发者_JS百科rns Table  
as  
return (select id, name, salary from employee) 

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


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

select * from dbo.emptable() 

not

select dbo.emptable() 


select * from dbo.emptable()

It's a table, after all...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜