输入banner图图片脚本导航/分类

分析sql语句所有表名及其别名的正则表达式

 

为了测试方便我使用了Combox来保存整理出来的表达式,于是取所有表和别名的代码是这样的

            DataTable table = new DataTable();
            table.Columns.Add("tableName");
            table.Columns.Add("aliasName");
            foreach (string str in this.comboBox1.Items)
            {
                Regex reg = new Regex(str);
                MatchCollection mces = reg.Matches(this.richTextBox1.Text);
                foreach (Match mc in mces)
                {
                    DataRow row = table.NewRow();
                    row["tableName"] = mc.Groups[1].Value;
                    row["aliasName"] = mc.Groups[2].Value;
                    table.Rows.Add(row);
                }
            }
            this.dataGridView1.DataSource = table.DefaultView;

以下是我用于测试的sql

select * from Outvisit l
left join patient p on l.patid=p.patientid
join patstatic c on   l.patid=c.patid inner join patphone  ph  on l.patid=ph.patid
where l.name=kevin and exsits(select 1 from pharmacywestpas p where p.outvisitid=l.outvisitid)
unit all
select * from invisit v where

最后是我测试的小程序的截图

技术分享

 

分析sql语句所有表名及其别名的正则表达式

标签: