Home > Database > Mysql Tutorial > 从数据库中导出数据

从数据库中导出数据

WBOY
Release: 2016-06-07 15:17:17
Original
1487 people have browsed it

首先开启xp_cmdshell权限: EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE; 1,导出数据到txt exec master..xp_cmdshell 'bcp 数据库名..表名 out 文件名t -c -t -U sa -P 密码' 2,导出数据到

首先开启xp_cmdshell权限:

 EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;

1,导出数据到txt

 exec master..xp_cmdshell 'bcp "数据库名..表名" out "文件名t" -c -t -U sa -P 密码'

 2,导出数据到excel

EXEC master..xp_cmdshell 'bcp 数据库名..表名 out 文件名 -c  -t -U sa -P 密码'

若是数据库表之间复制数据就没这么麻烦了,用如下sql语句

insert into 目标表名(字段1,字段2) select 源表名.字段1,源表名.字段2 from 源表名
 

同时要注意字段的类别一定要匹配。

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template