Solved

Exporting database to CSV files

Posted on 2010-09-21
6
731 Views
Last Modified: 2012-08-14
Pardon me for posting this in slightly the wrong place. I don't see any option for SQL in general or SQL 2000.

I need to export a SQL2000 data to CSV files. One for each table. Everything I am seeing says to use DTS. Following the examples I have found, I seem to be missing a step. The screen shots show a step where you can choose what tables are exported. I'm not getting that option. I get a drop down of all the tables, so I can only pick one.

If there is a way to make this work, or someone can point out another way to export all the table to individual CSVs, that would be great.

Thanks!
0
Comment
Question by:Brian B
6 Comments
 
LVL 5

Accepted Solution

by:
jijeesh earned 400 total points
Comment Utility
Use bcp you can do it..

declare @sql varchar(8000)
select @sql = 'bcp master..sysobjects out
                c:\bcp\sysobjects.txt -c -t, -T -S'+ @@servername
exec master..xp_cmdshell @sql


http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/
0
 
LVL 51

Expert Comment

by:HainKurt
Comment Utility
what is "examples" or tools are you using? where is the screenshot?
0
 
LVL 12

Assisted Solution

by:jagssidurala
jagssidurala earned 100 total points
Comment Utility
its is a simple application to get the csv file by entering the table name.

http://www.codeproject.com/KB/aspnet/ImportExportCSV.aspx

This link will give you an idea to get csv file by a sql query.
 
http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 23

Author Comment

by:Brian B
Comment Utility
The link on the simple-talk website is almost exactly what I need. In fact I ran it and got all my data exported. Then I realized that BCP doesn't export the columns names. I have looked up how to include them, but again the samples are only written for one table, not the entire database.

Here's the code I am using to generate another page of code that I run to produce the export. How would I modify this to include column names?

select 'exec master..xp_cmdshell'
             + ' '''
             + 'bcp'
             + ' ' + TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME
             + ' out'
             + ' e:\export\'
             + TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME + '.bcp'
             + ' -t, -T -S' + @@servername
             + ''''
from INFORMATION_SCHEMA.TABLES
where TABLE_TYPE = 'BASE TABLE'
0
 
LVL 23

Author Comment

by:Brian B
Comment Utility
I finally hit on the right combination of search words and found a great little utility called SQLtoTXT (http://www.withdata.com/sqltotxt.html) that did the trick. The trial version will only export the first 1000 records from each table, but I just did manual export for those.

Thanks everyone for your help and time.
0
 
LVL 23

Author Closing Comment

by:Brian B
Comment Utility
Although this wasn't the final solution I used, the informationw as still helpful. Thanks!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now