I'm creating a SQL Server function in SQL Server 2000. My syntax is about like this:
ALTER FUNCTION dbo.test()
RETURNS TABLE
AS
RETURN
(
DECLARE @A VARCHAR(100)
DECLARE @B VARCHAR(100)
SELECT @A='abc', @B='bca'
SELECT A=@A, B=@B
)
I'm trying to declare a variable and select it as a return value, but I'm getting this error message:
Msg 156, Level 15, State 1, Procedure test, Line 6
Incorrect syntax near the keyword 'DECLARE'.
Msg 170, Level 15, State 1, Procedure test, Line 10
Line 10: Incorrect syntax near ')'.
Seems it wont accept a variable declaration. What's the problem? Thanks in advance.