Using BCP to guide SQL Server data to an Excel file

Source: Internet
Author: User

It is convenient for SQL Server to export data using bcp, for example, to export Pubs.dbo.sales records into Excel format, and at the command prompt, enter:

(1) Specify table or view name export

BCP pubs.dbo.sales out c:\exp.xls-w-S testdb-u "sa"-P "password"

(2) Using SELECT query statements to generate data to mourn out

BCP "SELECT * from Pubs.dbo.sales" queryout c:\exp.xls-w-S Testdb-u "sa"-P "password"

Parameter description:

-S is followed by the SQL Server service name, which is executed on the database server and is not required for this parameter.

-U is followed by user name, note that the parameter is large under

The password is entered after-p

If you are executing on a server, you can use Windows trust relationships with the-t parameter

BCP "SELECT * from Pubs.dbo.sales" queryout c:\exp.xls-w-S TESTDB-T

Using BCP to guide SQL Server data to an Excel file

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.