怎么调用临时表的删除出错阿?drop table #t1
yixia 2004-11-08 11:58:35 String s1 = "select IDENTITY (int) id ,SKSPSI,SKDATE, SKKAIT into #t1 FROM IESPP "+
" INNER JOIN IESKP ON IESPP.SPSINO=IESKP.SKSINO ORDER BY IESKP.SKDATE ";
String s2 = "select top 3 id,SKDATE, SKKAIT from #t1 where SKSPSI='S' order by SKDATE
desc";
String s3 = "drop table #t1";
try{
drv = (Driver)Class.forName"com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
}
catch(Exception e){
}
try{
conn = DriverManager.getConnection(url,userid,pass);
}
catch(SQLException e){
}
if (conn == null)
System.out.println("error1");
try {
stmt = conn.createStatement();
stmt.execute(s1);
ResultSet rs = stmt.executeQuery(s2);
while(rs.next()){
System.out.println(rs.getString(1)+","+rs.getString(2)+","+rs.getString(3));
}
pstmt = conn.prepareStatement(s3);
pstmt.execute(); //删除临时表
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
stmt.close();
pstmt.close();
conn.close();
} catch (SQLException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}