Use xp_cmdshell to export files to local and network paths.

Source: Internet
Author: User

Chi Junchang

1. Export to Local:

--Create a Test folder. Master.. xp_cmdshell ' mkdir E:\Test\ '
--Export the file to a local, including the native database connection method.
EXEC Master. xp_cmdshell ' bcp '  landahz. Prtobank "Out" \e:\ Payroll file \ file name. xls "  -c-q-S". \sql2008 "-u" sa "-P" 123456 "

2. Export to a folder under the network path.

--How to create a network map connection. EXEC master. xp_cmdshell ' net use <a target=_blank href= "file://\\192.168.0.1" >\\192.168.0.1</a> "password"/user: username '

After the test passes:

--Create a folder on the network path. Master.. xp_cmdshell ' mkdir <a target=_blank href= "file://\\192.168.0.1\e$\" >\\192.168.0.1\E$\</a> Payroll file \ '
<pre class= "SQL" name= "code" >--the export file to the network path, including how the native database is connected. EXEC Master. xp_cmdshell ' bcp '  landahz. Prtobank "Out" \\192.168.0.1\E$\ Payroll file \ file name. xls "  -c-q-S". \sql2008 "-u" sa "-P" 123456 "



Use xp_cmdshell to export files to local and network paths.

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.