I have a user defined function which is used in many stored procedures which will return me some value. If it possible for me to add a new optional parameter to the same.
I think the easiest way is to make a stored procedure CalculateAverageForUserAndType(int userid ,type NVARCHAR(10)) Put your original code inside the new procedure. Then change CalculateAverageForUser to
dbo.CalculateAverageForUser(int userid)
AS
BEGIN
EXEC CalculateAverageForUserAndType userid, NULL
END
This way you can slowly migrate to your new stored procedure and your old one still works.