SQL Server uses the miscellaneous notes

Source: Internet
Author: User

SQL Server Export Database

NAVCAT for SQL Server open connection, open database, right--data transfer, General tab--mode SELECT dbo, target select connection (select your new library) or file (export your desired SQL file location), click Start

Stuff Makes the table

CUSTOMER

1 shz

2 sz

1 Chinese

Into

CUSTOMER

1 Shz,chinese

2 sz

Select No,stuff ((select ', ' + login_name from customer where NO = a.no FOR XML Path ("))," ("),") from customer a

Stored procedure (returns a list of records)

PROCEDURE [dbo]. [Get_customer]
@No varchar (10),
@beginTime varchar (19),
@endTime varchar (19)
As
BEGIN
Select No, loginname,age where CONVERT (varchar, open_time,) between @beginTime and @endTime and [email protect Ed
ORDER by Info.agent_no;
END

Hibernate calls a stored procedure where query does not support paging of stored procedures, and can of course be written to the stored procedure

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 (:p arm1,:p arm2,:p arm3)}");
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 uses the miscellaneous notes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.