CREATE PROCEDURE dbo.getSources (
  @SiteID uniqueidentifier = NULL
) AS
IF (@SiteID IS NULL)
  SELECT [LogSource].[ID], [Site], [FilePath], [Status], [Parser],
    [LineNumber], [Length], [LastWrite], [ReProc], [Comment] FROM
    [LogSource] INNER JOIN [LogSite] ON
    [LogSource].[Site] = [LogSite].[ID] ORDER BY [LogSite].[SiteIndex]
ELSE
  SELECT [ID], [Site], [FilePath], [Status], [Parser], [LineNumber], 
    [Length], [LastWrite], [ReProc], [Comment] FROM [LogSource] 
    WHERE [Site] = @SiteID ORDER BY [FilePath]
