110,538
社区成员
发帖
与我相关
我的任务
分享
resultSQL=Regex.Replace(yourSQL, "^(?is)select.+?from", "select count(*) from ")
regx = new Regex(@"(?<=^\s*select\s)(?:(?!\bfrom\b).)+(?=\sfrom)", RegexOptions.IgnoreCase);
commandText = regx.Replace(commandText, "count(1)");
regx = new Regex(@"order\s+by\s+\w+", RegexOptions.IgnoreCase);
commandText = regx.Replace(commandText, "");
(?<=select) .+ (?=from table1)