SQL 2000 does not allow me to create a table variable or UDF. I am sure my syntax is correct but it gives me a syntax error near 'create' or near 'table'. This db was originally ported from SQL 6.5->7.0->2000. Can anyone explain?
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'function'.
Server: Msg 137, Level 15, State 1, Line 13
Must declare the variable '@Passedinvalue'.
Server: Msg 178, Level 15, State 1, Line 19
A RETURN statement with a return value cannot be used in this context.
This seems to happen on the production db on the server. I could execute the same piece of code in a dev copy db.
A concrete example might be better...this does what you want...yes I got the same bugs trying to compile your code...but this will do what you want...
CREATE FUNCTION udf_Concat(@x int)
DECLARE @Outputstr VARCHAR(8000)
SET @Outputstr = ''
SELECT @Outputstr = @Outputstr + CustomerId + '/'
WHERE EmployeeId = @x
SELECT @Outputstr = LEFT(@Outputstr,LEN(@Outputstr)-1)
DROP FUNCTION udf_Concat