sql user defined function

Posted by nectar on Stack Overflow See other posts from Stack Overflow or by nectar
Published on 2010-06-17T06:46:38Z Indexed on 2010/06/17 6:53 UTC
Read the original article Hit count: 152

Filed under:
|

for a table valued function in sql why cant we write sql statements inside begin and end tags like-

create function dbo.emptable()
returns Table
as
BEGIN --it throws an error
return (select id, name, salary from employee)
END
go

while in scalar valued function we can use these tags like

create function dbo.countemp()
returns int
as
begin
return (select count(*) from employee)
end
go

is there any specific rule where we should use BEGIN & END tags

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about tsql