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. The database has about 100 tables so I don't want to do this manually.
我的客户聘请的顾问要求以csv格式导出我们的一个SQL Server 2000数据库中所有表的前n行(约30或40行),包括第一行的列名。数据库有大约100个表,所以我不想手动执行此操作。
Can anyone recommend a script, tool or other approach that can do this quickly?
任何人都可以推荐一个可以快速完成此任务的脚本,工具或其他方法吗?
3 个解决方案
#1
1
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
渣子
#2
3
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. You can output the results to a text file
这将为您提供当前数据库中每个表的前30条记录。您可以将结果输出到文本文件
#3
1
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?
如果前三十行不是相关行,则前三十行是无用的。如果他不打算将它们用作测试数据(并且如果客户表中的前三行中有不同的客户ID作为订单表,则他不能使用它们),那么为什么不给他模式呢?
Also be wary of providing real data to someone to use for development purposes.
还要警惕向某人提供真实数据以用于开发目的。
#1
1
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
渣子
#2
3
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. You can output the results to a text file
这将为您提供当前数据库中每个表的前30条记录。您可以将结果输出到文本文件
#3
1
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?
如果前三十行不是相关行,则前三十行是无用的。如果他不打算将它们用作测试数据(并且如果客户表中的前三行中有不同的客户ID作为订单表,则他不能使用它们),那么为什么不给他模式呢?
Also be wary of providing real data to someone to use for development purposes.
还要警惕向某人提供真实数据以用于开发目的。