当前位置: 代码迷 >> Sql Server >> SQL语句结束符号是什么?该如何处理
  详细解决方案

SQL语句结束符号是什么?该如何处理

热度:54   发布时间:2016-04-27 16:38:58.0
SQL语句结束符号是什么?
我要一次执行3句SQL,但是
我用了;不行
应该是什么?

------解决方案--------------------
------------------或者这样写----------------

try {
String sql = " insert into social.grant4(personid,yearfr,monthfr,yearto,monthto,fee,operator,opertime) ";
sql += " select s.personid,@yearfr,@monthfr,@yearto,@monthto,@fee,@operator,GetDate() ";
sql += " from social.soclogin s,social.paysoc p,sqdta.community c,sqdta.street t ";
sql += " where s.personid=p.personid and p.ispay= '1 ' and s.livcomm = c.commid and c.streetid = t.streetid and t.branchid= ' "+strBranchID+ " ' ";

sql1 += " insert into social.grant3(commid,yearfr,monthfr,yearto,monthto,person,fee,total,operator,opertime) ";
sql1 += " select c.commid,@yearfr,@monthfr,@yearto,@monthto,count(personid),@fee,count(personid)[email protected],@operator,GetDate() ";
sql1 += " from social.soclogin s,social.paysoc p,sqdta.community c,sqdta.street t ";
sql1 += " where s.personid=p.personid and p.ispay= '1 ' and s.livcomm = c.commid and c.streetid = t.streetid and t.branchid= ' "+strBranchID+ " ' ";
sql1 += " group by c.commid ";

sql2 += " insert into social.grant2(streetid,yearfr,monthfr,yearto,monthto,person,fee,total,operator,opertime) ";
sql2 += " select t.streetid,@yearfr,@monthfr,@yearto,@monthto,count(personid),@fee,count(personid)[email protected],@operator,GetDate() ";
sql2 += " from social.soclogin s,social.paysoc p,sqdta.community c,sqdta.street t ";
sql2 += " where s.personid=p.personid and p.ispay= '1 ' and s.livcomm = c.commid and c.streetid = t.streetid and t.branchid= ' "+strBranchID+ " ' ";
sql2 += " group by t.streetid ";

sql3 += " insert into social.grant1(branch,yearfr,monthfr,yearto,monthto,person,fee,total,operator,opertime) ";
sql3 += " select t.branchid,@yearfr,@monthfr,@yearto,@monthto,count(personid),@fee,count(personid)[email protected],@operator,GetDate() ";
sql3 += " from social.soclogin s,social.paysoc p,sqdta.community c,sqdta.street t ";
sql3 += " where s.personid=p.personid and p.ispay= '1 ' and s.livcomm = c.commid and c.streetid = t.streetid and t.branchid= ' "+strBranchID+ " ' ";
sql3 += " group by t.branchid ";

conn = DbManager.getConnection();
pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();
pstmt1 = conn.prepareStatement(sql1);
pstmt1.executeUpdate();
pstmt2 = conn.prepareStatement(sql2);
pstmt2.executeUpdate();
pstmt3 = conn.prepareStatement(sql3);
pstmt3.executeUpdate();
  相关解决方案