A SQL parser does seem like the better solution, but I thought I'd try to write a regex anyway. This regular expression detects all the table names in the sample strings you provided. It's a bit messy and it's certainly possible that there are cases that this regex does not cover. It must be used with the IgnoreCase option.
(?<=(?:FROM|JOIN)[\s(]+)(?>\w+)(?=[\s)]*(?:\s+(?:AS\s+)?\w+)?(?:$|\s+(?:WHERE|ON|(?:LEFT|RIGHT)?\s+(?:(?:OUTER|INNER)\s+)?JOIN)))
Here is a piece of sample code that prefixes all the table names with "dbo.".
const string REGEX_MATCH_TABLE_NAME = @"(?<=(?:FROM|JOIN)[\s(]+)(?>\w+)(?=[\s)]*(?:\s+(?:AS\s+)?\w+)?(?:$|\s+(?:WHERE|ON|(?:LEFT|RIGHT)?\s+(?:(?:OUTER|INNER)\s+)?JOIN)))";
string testInput = "SELECT e.last_name,e.department_id, d.department_name FROM employees e LEFT OUTER JOIN department d ON ( e.department_id = d.department_id );";
string resultString = Regex.Replace(testInput, REGEX_MATCH_TABLE_NAME, "dbo.$0", RegexOptions.IgnoreCase | RegexOptions.Multiline);
Here is a rough breakdown of the regex:
(?<= #Begin positive lookbehind.
(?:FROM|JOIN) #Match keywords that usually preceed a table name.
[\s(]+
) #End positive lookbehind.
(?>\w+) #Match the table name. Atomic for faster failed matches.
(?= #Begin positive lookahead.
[\s)]*
(?:\s+(?:AS\s+)?\w+)? #Match the table alias that possibly follows the table name.
(?:$|\s+(?:WHERE|ON|(?:LEFT|RIGHT)?\s+(?:(?:OUTER|INNER)\s+)?JOIN)) #Match keywords that usually follow a table name.
) #End positive lookahead.