简体   繁体   English

SQL Server整个数据库csv导出

[英]SQL Server whole database csv export

A consultant employed by my client has asked for an export of the the first n rows (approx 30 or 40) of all the tables in one of our SQL Server 2000 databases in csv format, including column names on the first row. 我的客户雇用的一名顾问要求以csv格式导出我们SQL Server 2000数据库之一中所有表的前n行(大约30或40),包括第一行的列名。 The database has about 100 tables so I don't want to do this manually. 该数据库有大约100个表,所以我不想手动执行此操作。

Can anyone recommend a script, tool or other approach that can do this quickly? 任何人都可以推荐可以快速执行此操作的脚本,工具或其他方法吗?

Try this from enterprise manager 从企业经理那里尝试一下

EXEC sp_MSForEachTable 'SELECT top 30 * from ?'

This will give you the top 30 records from each table in the current database. 这将为您提供当前数据库中每个表的前30条记录。 You can output the results to a text file 您可以将结果输出到文本文件

You could potentially use the DTS (Data Transformation Services) of SQL Server 2000 and just export everything into an Excel sheet, no? 您可能会使用SQL Server 2000的DTS(数据转换服务),然后将所有内容导出到Excel工作表中,对吗?

Marc

The first thirty rows would be useless if they aren't the related rows. 如果前三十行不是相关行,那将毫无用处。 If he isn't going to use them as test data (and he can't if the customer table has different customer ids in it's first 30 rows as the orders table), then why not just give him the schema? 如果他不打算将它们用作测试数据(并且如果客户表的前30行与订单表中的客户表具有不同的客户ID,那么他就不能这样做),为什么不给他架构呢?

Also be wary of providing real data to someone to use for development purposes. 还要警惕将真实数据提供给某人以用于开发目的。

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

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