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.