errors:
In Microsoft SQL Server Management Studio Express:
In either case, it seems the "DECLARE" statement causes the error. Removing that line of code proves it.
Here's the minimal query:
In Microsoft SQL Server Management Studio Express:
In visual studio 2005:Msg 102, Level 15, State 1, Procedure fn_GetMessages, Line 2
Incorrect syntax near 'RETURNS'.
Msg 178, Level 15, State 1, Procedure fn_GetMessages, Line 6
A RETURN statement with a return value cannot be used in this context.
Incorrect syntax near the keyword 'DECLARE'.
A RETURN statement with a return value cannot be used in this context.
In either case, it seems the "DECLARE" statement causes the error. Removing that line of code proves it.
Here's the minimal query:
Code:
CREATE FUNCTION dbo.fn_GetRoles
RETURNS TABLE
AS
[b][red]DECLARE @some_variable int;[/red][/b]
RETURN
(
SELECT *
FROM [Roles]
)