开发者

Extract whole SQL Server database to CSV file

It is possible to extract all tables and rows of each table with one query 开发者_C百科or software in 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜