Skip to content
Advertisement

“Incorrect syntax near ‘RETURNS’. Expecting AS, FOR, or WITH.” (SQL User Defined Function) [closed]

Please review the SQL code below for a user-defined function I am trying to create. In SSMS, there seems to be an issue with this part of the code:

I am getting the error message:

Incorrect syntax near ‘RETURNS’. Expecting AS, FOR, or WITH.

SQL:

Advertisement

Answer

I think you are mixing up Stored procedure and Functions.You can return data from stored procedure using output variable or you can use return code. The return code will only return a integer value that is generally used as a status code. In your code , it looks like you would like to use Function rather then stored proc.

Please read below for better understanding –

https://docs.microsoft.com/en-us/sql/relational-databases/stored-procedures/return-data-from-a-stored-procedure?view=sql-server-2017

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement