CREATE PROCEDURE dbo.getRegisteredSites	(
  @MachineName nvarchar(15) = NULL
) AS
IF (@MachineName IS NULL)
  SELECT [ID], [MachineName], [SiteIndex], CONVERT(nvarchar(25),
    [MachineName] + N'W3SVC' + CONVERT(nvarchar(5), [SiteIndex])) AS
    [EntriesTable], CONVERT(nvarchar(256), NULL) AS [SiteName],
    CONVERT(nvarchar(512), NULL) As [LogFileDirectory], CONVERT(bit, 1)
    AS [Registered] FROM [LogSite] ORDER BY [MachineName], [SiteIndex]
ELSE
  SELECT [ID], [MachineName], [SiteIndex], CONVERT(nvarchar(25),
    [MachineName] + N'W3SVC' + CONVERT(nvarchar(5), [SiteIndex])) AS
    [EntriesTable], CONVERT(nvarchar(256), NULL)
    AS [SiteName], CONVERT(nvarchar(512), NULL) As [LogFileDirectory], 
    CONVERT(bit, 1) AS [Registered] FROM [LogSite] 
    WHERE [MachineName] = @MachineName ORDER BY [SiteIndex]
RETURN
