简体   繁体   English

将整个SQL Server数据库提取到CSV文件

[英]Extract whole SQL Server database to CSV file

It is possible to extract all tables and rows of each table with one query or software in microsoft sql server? 是否可以使用Microsoft SQL Server中的一个查询或软件提取所有表和每个表的行?

thanks 谢谢

You can do this by using the Import/Export Wizard. 您可以通过使用导入/导出向导来执行此操作。 (Right Click database -> Tasks -> Import/Export Wizard) (右键单击数据库->任务->导入/导出向导)

Or for greater control you could use SSIS. 或者为了获得更大的控制权,可以使用SSIS。

The above answer is correct but if this is something you want to script and do regularly, this might get you started: 上面的答案是正确的,但是如果这是您要编写脚本并定期进行的操作,则可能会使您入门:

exec sp_msforeachtable 'exec xp_cmdshell ''bcp database_name.? out c:\?.csv -S server_name -T -c -t ","'''

Caution... This uses an undocumented stored procedure and assumes that xp_cmdshell is enabled and that the xp_xmdshell account has rights to sql server. 警告...这将使用未记录的存储过程,并假定已启用xp_cmdshell,并且xp_xmdshell帐户具有sql server的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM