Home > Archive > SQL server exams > September 2002 > Coco's question of the Week #6





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Coco's question of the Week #6
cocolocopolo

2002-09-10, 1:22 am

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 !!
2lazybutsmart

2002-09-10, 7:23 am

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.
cocolocopolo

2002-09-11, 1:38 am

Thanks 2lazybutsmart.

It seems I am too careless.
Sponsored Links





Free Braindumps | MCSE braindumps software forum

Copyright 2003 - 2008 examnotes.net