拆分sql生成多条插入记录

拆分sql生成多条插入记录
 StringBuilder tempSB = new StringBuilder();
            DataTable tempDT =  dba.GetTable("select newid() Gid,BusID,SecId,SecName,BusName,remark from tbl_BuTmp");
            string Bid = "", BCode, SId, SName, PBName, Rmark;
            for (int i = 0; i < tempDT.Rows.Count; i++)
            {
                Bid = Common.StringOperator.GetRightString(tempDT.Rows[i]["Gid"]);
                BCode = Common.StringOperator.GetRightString(tempDT.Rows[i]["BusID"]);
                SId = Common.StringOperator.GetRightString(tempDT.Rows[i]["SecId"]);
                SName = Common.StringOperator.GetRightString(tempDT.Rows[i]["SecName"]);
                PBName = Common.StringOperator.GetRightString(tempDT.Rows[i]["BusName"]);
                Rmark = Common.StringOperator.GetRightString(tempDT.Rows[i]["remark"]);
                foreach (string tempRemark in Rmark.Split(';'))
                {
                    tempSB.AppendFormat("insert into tbl_ProB(ProBusinessID,BusinessFlowCode,SectionID,SectionName,ProBusinessName,Remark) values('{0}','{1}','{2}','{3}','{4}','{5}')" + System.Environment.NewLine, System.Guid.NewGuid(), BCode, SId, SName, tempRemark, tempRemark);
                }
               
            }
            this.richTextBox1.Text = tempSB.ToString();
            this.dataGridView1.DataSource=tempDT;

你可能感兴趣的:(拆分sql生成多条插入记录)