Hi,I'm trying top retrieve information based on parameters sent to the procedure.i need to go into an IF satement in order for me to check if i need to set the parameter value or to use the inputed one.I get en error for the IF statement.can someone please advice me whats wrong?ALTER PROCEDURE [dbo].[LeagueTableProcedure] @league int=null, @nation int=null , @season int=null Output, @round int=nullASbeginif @league=nullSELECT @league=Competitions.CompetitionId, @season=Seasons.Seasonid, @round=Rounds.RoundIdFROM Competitions INNER JOIN Seasons ON Competitions.CompetitionId = Seasons.CompetitionId INNER JOIN Rounds ON Seasons.Seasonid = Rounds.SeasonIdWHERE (Competitions.AreaId = @nation) AND (Seasons.EndDate > getdate())end ifIF (@season=null)SELECT @season=Seasons.Seasonid, @round=Rounds.RoundIdFROM Competitions INNER JOIN Seasons ON Competitions.CompetitionId = Seasons.CompetitionId INNER JOIN Rounds ON Seasons.Seasonid = Rounds.SeasonIdWHERE (Competitions.AreaId = @nation) AND (Seasons.EndDate > GETDATE()) AND (Competitions.CompetitionId = @league) AND (Rounds.RoundEnd > GETDATE())end ifif @round=null then beginSELECT @round=Rounds.RoundIdFROM Seasons INNER JOIN Rounds ON Seasons.Seasonid = Rounds.SeasonIdWHERE (Rounds.RoundEnd > GETDATE())endend ifendSELECT t.Team_name, t.TeamID, lt.rank, lt.MatchWon, lt.MatchDraw, lt.MatchLost, lt.points, lt.GoalsScored, lt.GoalsRecieved, la.rank AS awayRank, la.MatchWon AS awayWon, la.MatchDraw AS awayDraw, la.MatchLost AS awayLost, la.points AS awayPoints, la.GoalsScored AS awayScored, la.GoalsRecieved AS awayRecieved, lh.rank AS homeRank, lh.MatchWon AS homeWon, lh.MatchDraw AS homeDraw, lh.MatchLost AS homeLost, lh.points AS homePoints, lh.GoalsScored AS homeScored, lh.GoalsRecieved AS homeRecieved, (SELECT COUNT(TeamTableInfo.TeamID) AS Expr1 FROM Seasons INNER JOIN Competitions ON Seasons.CompetitionId = Competitions.CompetitionId INNER JOIN Rounds ON Seasons.Seasonid = Rounds.SeasonId INNER JOIN TeamTableInfo INNER JOIN LeagueTableTotal ON TeamTableInfo.TeamID = LeagueTableTotal.TeamId ON Rounds.RoundId = LeagueTableTotal.RoundId WHERE (Seasons.CompetitionId = @league) AND (t.TeamID = TeamTableInfo.TeamID) GROUP BY TeamTableInfo.TeamID) AS gamePlayed, t.TeamID AS Expr1FROM Seasons AS s INNER JOIN Competitions AS c ON s.CompetitionId = c.CompetitionId INNER JOIN Rounds AS r ON s.Seasonid = r.SeasonId INNER JOIN TeamTableInfo AS t INNER JOIN LeagueTableTotal AS lt ON t.TeamID = lt.TeamId ON r.RoundId = lt.RoundId INNER JOIN LeagueTableAway AS la ON r.RoundId = la.RoundId INNER JOIN LeagueTableHome AS lh ON r.RoundId = lh.RoundIdWHERE (r.RoundId = @round)