標籤:http io ar 使用 for sp 檔案 資料 on
SqlServer匯出資料庫
navcat for sql server中開啟串連,開啟資料庫,右鍵--資料轉送,常規選項卡--模式選擇dbo,目標選擇串連(選擇你建立的庫)或者檔案(匯出你要的sql檔案位置),點擊開始
stuff使得表
CUSTOMER
1 shz
2 sz
1 Chinese
轉為
CUSTOMER
1 shz,Chinese
2 sz
select NO,stuff((select ‘,‘ + LOGIN_NAME from CUSTOMER where NO = a.NO for xml path(‘‘)),1,1,‘‘) from CUSTOMER a
預存程序(返回記錄列表)
PROCEDURE [dbo].[get_customer]
@No varchar(10),
@beginTime varchar(19),
@endTime varchar(19)
AS
BEGIN
select no, loginName,age where CONVERT(varchar, open_time, 120) between @beginTime and @endTime and [email protected]
ORDER BY info.agent_no;
END
hibernate調用預存程序(其中Query不支援預存程序的分頁,當然可以將分頁寫入預存程序中)
public List<Customer> getAllCustomer(final String No,final Date beginTime,final Date endTime) {
return (List<Customer>) getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createSQLQuery("{CALL get_customer(:parm1, :parm2, :parm3)}");
query.setParameter("parm1", agentNo);
query.setParameter("parm2", XADateUtil.getDateW3CFormat(beginTime));
query.setParameter("parm3", XADateUtil.getDateW3CFormat(endTime));
List arr = query.list();
List<Customer> list = new ArrayList();
if(arr==null)return null;
for (int i = 0; i < arr.size(); i++) {
Object[] ob = (Object[]) arr.get(i);
Customerpl = new Customer();
pl.setNo((String) ob[0]);
pl.setLoginName((String) ob[1]);
list.add(pl);
}
return list;
}
});
}
sql server使用雜記