











|  |
| Author |
Coco's question of the Week #6
|
cocolocopolo
Senior Member
Registered: Apr 2001 Location: Los Angeles Country: USA State: Certifications: A+, Network+, CCNA Working on: MCDBA
Total Posts: 287
|
|
Coco's question of the Week #6
I practised to create a function as follows:
Create Function fnEmployeeByDepartment (@DepartmentID int)
Return Table
As
Return (Select * From Employee Where DepartmetnID = @DepartmentID)
Go
But I got following error:
=================
Server: Msg 156, Level 15, State 1, Procedure fnEmployeeByDepartment, Line 2
Incorrect syntax near the keyword 'Return'.
Server: Msg 178, Level 15, State 1, Procedure fnEmployeeByDepartment, Line 4
A RETURN statement with a return value cannot be used in this context.
Please h-e-l-p !!
__________________
cocolocopolo
Report this post to a moderator
|
|
09-10-02 07:22 AM
|
|
2lazybutsmart
The Game Never Ends

Registered: Jun 2002 Location: Toronto Country: Canada State: Certifications: MCSD, MCP Working on: MCSD.net, MCDBA, MCT
Total Posts: 684
|
|
the first RETURN is "RETURNS" with a "S". don't forget that. the rest of ur function is two thumbs-up. make that slight change and ur off like a rocket.
so ur functio would look like this:
---------------
CREATE FUNCTION fnEmployeeByDepartment (@DepartmentID int)
RETURNS Table
AS
RETURN (Select * From Employee Where DepartmetnID = @DepartmentID)
Go
----------
cheers.
__________________
Crime is Common, Logic is Rare.
TechExams.net moderator
Report this post to a moderator
|
|
09-10-02 01:23 PM
|
|
cocolocopolo
Senior Member
Registered: Apr 2001 Location: Los Angeles Country: USA State: Certifications: A+, Network+, CCNA Working on: MCDBA
Total Posts: 287
|
|
|
09-11-02 07:38 AM
|
|
|
Forum Rules: Who Can Read The Forum? Any registered user or guest.
Who Can Post New Topics? Any registered user.
Who Can Post Replies? Any registered user.
Changes: Messages can be edited by their author.
Posts: HTML code is OFF. Smilies are ON. vB code is ON. [IMG] code is ON. |
|
ExamNotes forum archive
|