- select top 100 Date, Workstation, EventType, Name from EventLog LEFT OUTER JOIN Principal ON EventLog.UserId = Principal.Id where EventType = @eventType and (Workstation like @workstation+'%' or @workstation='') and (datediff( day, @dateFrom, Date)>=0 or @dateFrom is null) and (datediff( day, Date, @dateTo)>=0 or @dateTo is null) - - -