I'm having an issue with SQL Server 2008, I want to write a function that returns the sum of a specific column, the code goes like this:
CREATE FUNCTION [dbo].[GetIssuesSum](@i int)
RETURNS int
AS
BEGIN
DECLARE @IssueSum int
SELECT SUM (@IssueSum = Quantity)
FROM Issue
RETURN @IssueSum
END
When I try to execute it, SQL Server 2008 throws this error
Msg 102, Level 15, State 1, Procedure GetIssuesSum, Line 15
Incorrect syntax near '='.
Any suggestions? Thanks in advance